HTML Manipulation using jQuery

Using jQuery we can perform different methods of HTML manipulations.

For example if  you want to add the contents to the HTML elements you can use  jQuery append() or prepend()

Now let us see some of the jQuery manipulation functions

1. html() and text()

Both html() and text() returns or sets the contents of selected elements

EXAMPLE:

2. Append() and Prepend()

Append() adds the content to the end of the selected element

Prepend() adds the content to the beginning of the selected element

EXAMPLE:

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
 $("button").click(function(){
 $("p").prepend("<b>Hai!</b> ");
 });
});
</script>
</head>
<body>
<p>Welcome to Learnwebdevelopment.info</p>
<button>append</button>
</body>
</html>
Posted in jQuery Tagged with: