This method is used to insert the data at the beginning of the selected elements . It is just opposite of the append( ) method . Append ( ) method is used to insert the data at the end of selected elements . Syntax :
$(selector).prepend(content,function(index,html))
Example : HTML Code :
<html>
<head></head>
<body>
<button id="button1">After click ,Data added at the beginning of p tag</button>
<p>Hello Mukesh Tomar</p>
<p>From Meerut</p>
</body>
</html>
jQuery Code :
$(funtion(){
$("#button1").click(function(){
$("p").prepend("<b>I have added at the beginning of p tag</b>");
});
});
Output :
I have added at the beginning of p tag.Hello Mukesh Tomar
I have added at the beginning of p tag .From Meerut
0 Comment(s)