Query - Get Content and AttributesSet Attributes - text() -html() - val()
Three simple, but useful, jQuery methods for DOM manipulation is:
$("#btn1").click(function(){("Text: " + $("#test").text());)} $("#btn2").click(function(){"HTML: " + $("#test").html()); $("#btn1").click(function(){"Value: " + $("#test").val());
Get Attributes - attr()
$("button").click(function(){ $("#w3s").attr("href"));
Set Attributes
Set Attributes - text() -html() - val()
We will use the same three methods from the previous page to set content:
$("#btn1").click(function(){ $("#test1").text("Hello world!"); $("#btn2").click(function(){"#test2").html("<b>Hello world!</b>"); $("#btn3").click(function(){"#test3").val("Dolly Duck");
Set Attributes - attr()
$("button").click(function(){ $("#w3s").attr("href","http://www.w3schools.com/jquery");)}
|