Before After Prepend Append
The following properties are used to insert any content , anywhere of your webpage.Before
Insert the content before the target HTML element.
--------------
--------------
$("#id").before("<b>I am in before the element</b>");
--------------
--------------
--------------
$("#id").before("<b>I am in before the element</b>");
--------------
--------------
After
Insert the content after the target HTML element.
--------------
--------------
$("#id").after("<b>I am in after the element</b>");
--------------
--------------
--------------
$("#id").after("<b>I am in after the element</b>");
--------------
--------------
Prepend
Inside the content but before existing content.
--------------
--------------
$("#id").prepend("<div style='border:solid 2px red;'></div>");
--------------
--------------
--------------
$("#id").prepend("<div style='border:solid 2px red;'></div>");
--------------
--------------
Append
Insert the div after the targeted HTML element.
--------------
--------------
$("#id").append("<div>I am after the div</div>");
--------------
--------------
--------------
$("#id").append("<div>I am after the div</div>");
--------------
--------------
Example Program:- (Editor)
Output:-
Advertisement
0 comments:
Post a Comment