This post is about and easy way to add and remove any kind of element in your web using JQuery functions.
.append()
<script>
$("#link").click(function(){
$("#add").append(" <b>Appended text</b>.");
});
</script>
<html>
<div id="add"></div>
<p id="link">Append text</p>
</html>
This example just add some Text to the div with id="add".
.empty()
<script>
$("#link-empty").click(function(){
$("#add").empty();
});
</script>
<html>And this example is going to empty all the elements of the div with id="add" only on click in the Remove text.
<div id="add"></div>
<p id="link-empty">Empty Div </p>
</html>
.remove()
<script>
$("#link-remove").click(function(){
$("#add").remove();
});
</script>
<html>And this example is going to all Div (add) from your site.
<div id="add"></div>
<p id="link-remove">Remove Div</p>
</html>
I'm using the JQuery library jquery-1.10.1.js. Download
No comments:
Post a Comment