<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()
{
var content = $(this).html();
$("#res").text(content);
});
});
</script>
<style>
#d1
{
margin:20px;
padding:24px;
border:4px solid #666;
width:80px;
}
</style>
</head>
<body>
<p> Click on the square </p>
<span id ="res"> </span>
<div id = "d1" style = "background-color:green;"> Its a green color square!!! </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).replaceWith("<h4>JQuery is simple</h4>");
});
});
</script>
<style>
#d1
{
margin:20px;
padding:24px;
border:4px solid #666;
width:80px;
}
</style>
</head>
<body>
<p> Click on the square </p>
<span id ="res"> </span>
<div id = "d1" style = "background-color:green;"> Its a green color square!!! </div>
</body>
</html>