December 2013
Intermediate to advanced
384 pages
9h 54m
English
var newP = $("<p></p>"); newP.html("This is the first paragraph."); $("div").prepend(newP); newP.html("This is the last paragraph."); $("div").append(newP);
You can also use the .prepend() and .append() methods in jQuery to prepend or append content to the element. Another major advantage of jQuery is that you can append HTML DOM elements created using the jQuery constructor jquery(htmlString) or $(htmlString) to add new HTML elements to the page. For example, the following code constructs a jQuery object with a <p> element, sets the content of the new paragraph element using .html(), and then appends the paragraph to all <div> elements.
var ...
Read now
Unlock full access