<html>
<head>
<script type = "text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js">
</script>
<script type="text/javascript" language ="javascript">
$(document).ready(function()
{
$("div").click(function()
{
$(this).remove();
});
});
</script>
<style>
.div
{
margin:20px;
padding:24px;
border:4px solid #666;
width:80px;
}
</style>
</head>
<body>
<p> Click on any of the square </p>
<div class = "div" style = "background-color:green;"></div>
<div class = "div" style = "background-color:red;"></div>
<div class = "div" style = "background-color:orange;"></div>
</body>
</html>
<html>
<head>
<script type = "text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js">
</script>
<script type="text/javascript" language ="javascript">
$(document).ready(function()
{
$("div").click(function()
{
$(this).before('<div class="div"></div>');
});
});
</script>
<style>
.div
{
margin:20px;
padding:24px;
border:4px solid #666;
width:80px;
}
</style>
</head>
<body>
<p> Click on any of the square </p>
<div class = "div" style = "background-color:green;"></div>
<div class = "div" style = "background-color:red;"></div>
<div class = "div" style = "background-color:orange;"></div>
</body>
</html>