jQuery
DOM Manipulation
DOM
– Document Object Model
(DOM
defines a standard for accessing HTML and XML)
Get
content – text(),
html(), val()
text()
: returns the text
content of selected element
html()
: returns the content
of selected element including HTML markup.
val()
: returns the value
of the form fields.
$("#output").val($("#textpara").text());
$("#output").val($("#textpara").html());
Get
Attributes –
attr()
- used
to get the attribute values
<input
type="text"
id="output"
width="200"
size="50"
/>
$("#output").attr("type")
→ “text”
$("#output").attr("width")
→ “200”
$("#output").attr("size")
→ “50”
Set
content –
text(),
html(), val()
Set
the content by using these methods.
$("#textpara").text("Hello
Sanjeeva");
$("#textpara").html("<b>Hello
Sanjeeva</b>");
$("#textpara").val("<b>Hello
Sanjeeva</b>");
Set
Attributes –
attr()
- Set
or change attribute values.
$("#output").attr("size","75");
jQuery
- css()
The
css() method sets or returns one or more style properties for the
selected elements.
Syntax
: css("propertyname","value");
Ex 01: - $("#animateabsoluteDiv").css("text-align","center");
Ex 02: - Set
multiple CSS,
$("#animateabsoluteDiv").css({"text-align","center","font-size":"200%"});