December 2013
Intermediate to advanced
384 pages
9h 54m
English
Often, you will not know all the elements that belong on a web page until a user begins using it, or you will receive additional information from a web service or some other interaction. In those cases, you may need to be able to add or replace element content on the fly using jQuery and JavaScript code.
The text of the element content is stored in the innerHTML attribute of the DOM element. You can change the content using JavaScript simply by setting the innerHTML to the new content. For example:
document.getElementById("#p1").innerHTML = "New Text";
In jQuery, you can change the innerHTML content using the .html() method, which gets or sets the innerHTML sting. For ...
Read now
Unlock full access