December 2013
Intermediate to advanced
384 pages
9h 54m
English
$("#p1").prepend("*New* :"); $("#p1").append(". . .read");
Another common dynamic task is adding text to a basic HTML element such as a span or paragraph. jQuery makes this extremely simple using the .append() method. This method appends content to the end of the element’s current content. It doesn’t matter if the content is a string or other elements.
For example, the following code appends the text ". . .read" to a paragraph with id="p1":
$("#p1").append(". . .read");
You may also want to prepend text to the beginning of an element’s content. In jQuery, the .prepend() method prepends content to the beginning of the element’s ...
Read now
Unlock full access