Jquery Get
jQuery - Get Content together with Attributes
jQuery contains powerful methods for changing together with manipulating HTML elements together with attributes.
jQuery DOM Manipulation
One real of import constituent of jQuery is the possibility to manipulate the DOM.jQuery comes amongst a bunch of DOM related methods that arrive slow to access together with manipulate elements together with attributes.
DOM = Document Object Model
The DOM defines a measure for accessing HTML together with XML documents:
"The W3C Document Object Model (DOM) is a platform together with language-neutral interface that allows programs together with scripts to dynamically access together with update the content, structure, together with fashion of a document."
The DOM defines a measure for accessing HTML together with XML documents:
"The W3C Document Object Model (DOM) is a platform together with language-neutral interface that allows programs together with scripts to dynamically access together with update the content, structure, together with fashion of a document."
Get Content - text(), html(), together with val()
Three simple, exactly useful, jQuery methods for DOM manipulation are:- text() - Sets or returns the text content of selected elements
- html() - Sets or returns the content of selected elements (including HTML markup)
- val() - Sets or returns the value of cast fields
Example
$("#btn1").click(function(){
alert("Text: " + $("#test").text());
});
$("#btn2").click(function(){
alert("HTML: " + $("#test").html());
});
Example
$("#btn1").click(function(){
alert("Value: " + $("#test").val());
});
Get Attributes - attr()
The jQuery attr() method is used to choke attribute values.The next event demonstrates how to choke the value of the href attribute inwards a link:
Example
$("button").click(function(){
alert($("#w3s").attr("href"));
});
Comments
Post a Comment