jQuery: The Write Less, Do More JavaScript Library

Error: Failed to load processor NavWiki
No macro or processor named 'NavWiki' found

As of jQuery 1.0, the jQuery object (returned by

Error: Failed to load processor Expression
No macro or processor named 'Expression' found

) has two new read-write attributes:

  • html(h)
  • val(h)

and one read-only attribute:

  • text()

$(expression).html(h)

Error: Failed to load processor param
No macro or processor named 'param' found

Description

If the optional h parameter is passed, sets the innerHTML of all elements returned by

Error: Failed to load processor Expression
No macro or processor named 'Expression' found

to the text of the parameter. If the parameter is not passed, returns the innerHTML of the first element matched by the

Error: Failed to load processor Expression
No macro or processor named 'Expression' found

.

Examples

$('p').html()

returns the innerHTML of the first <p> element.

$('p').html("inside")

set the innerHTML of all <p> elements to "inside"

$(expression).val(h)

Error: Failed to load processor param
No macro or processor named 'param' found

Description

If the optional h parameter is passed, sets the value attribute for all matching elements to the text of the parameter. If the parameter is not passed, returns the value attribute of the first element matched by the expression.

Examples

$('input').val()

returns the value of the first <input> element.

$('input').val("1")

sets the value of all <input> elements to "1".

$(expression).text()

Description

Returns the concatenated text contents of all matching elements.

Examples

$('p').text()

returns the text contents of all <p> elements, concatenated.