Home > Web Front-end > JS Tutorial > jQuery gets content and attributes sample code_jquery

jQuery gets content and attributes sample code_jquery

WBOY
Release: 2016-05-16 17:03:16
Original
1316 people have browsed it

Get content - text(), html() and val()

Three simple and practical jQuery methods for DOM manipulation:

text() - Set or return the selected element's Text content
html() - Sets or returns the content of the selected element (including HTML tags)
val() - Sets or returns the value of a form field

Get attributes - attr()

jQuery attr() method is used to get the attribute value.

The following example demonstrates how to get the value of the href attribute in the link:
Example

Copy code Code As follows:

$("button").click(function(){
alert($("#w3s").attr("href"));
}) ;
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template