Virtual Classes Logo          Virtual Classes
    Read Anytime,Anywhere

Modify Page Content

Following are the method provided by JQuery to modify page contents.
1-append() - Inserts content at the end of the selected elements
Example: $("p").append("Some appended text.");

2-prepend() - Inserts content at the beginning of the selected elements
Example: $("p").prepend("Some prepended text.");

3-after() - Inserts content after the selected elements
Example:$("img").after("Some text after");

4-before() - Inserts content before the selected elements
Example:$("img").before("Some text before");

5-remove() -Removes the selected element (and its child elements)
Example:$(“div1").remove();

6-empty() -Removes the child elements from the selected element
Example:$("#div1").empty();

7-attr()-JQuery attr()method is also used to set/change attribute values.
Example
$("button").click(function(){
$("#coName").attr("href", “http://virtualclasses.co.in");
});

The attr() method also allows you to set multiple attributes at the same time.
Example
$("button").click(function(){
$("#coName").attr({
      "href" : "http://virtualclasses.co.in",
      "title" : “Training on Jquery"      });
});