Friday 1 June 2012

How TO Remove the Contents of a Div using JQuery


This  will show how to write a text/content into a div using  jquery and also it will show how to remove text/content.

<html>
 <head>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
 <script>
 $(document).ready(function() {
 $("#click_me").click(function() {
 $("#write_me").html("Hello..Here I am  using jquery");
 });

$("#clear_me").click(function() {
 $("#write_me").empty();
 });

});
 </script>
 </head>
 <body>
 <div id="write_me"></div>
 <input type="button" id="click_me" name="click_me" value="Write into the div">
 <input type="button" id="clear_me" name="clear_me" value="Clear Me">
 </body>

</html>


No comments:

Post a Comment