jQuery-capture
jQuery has powerful methods for manipulating HTML elements and attributes.
jQuery DOM operation
A very important part of jQuery is the ability to operate DOM.
jQuery provides a set of DOM-related methods that make it easy to access and manipulate elements and attributes.
DOM = Document Object Model
DOM definition accesses HTML and XML documents Standard:
"The W3C Document Object Model is a platform- and language-independent interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
Get content - text( ), html() and val()
Three simple and practical jQuery methods for DOM operations:
text() - Set or return the text content of the selected element html() - Set or return the content of the selected element (including HTML tags) val() - Set or return the value of a form field
这是段落中的 粗体 文本。
The following example demonstrates how to get the value of an input field through the jQuery val() method:
Get attributes - attr()
jQuery attr() method is used to get attribute values.
The following example demonstrates how to get the value of the href attribute in the link: