Home > Web Front-end > JS Tutorial > jQuery gets content and attributes methods and examples_jquery

jQuery gets content and attributes methods and examples_jquery

WBOY
Release: 2016-05-16 17:11:03
Original
1448 people have browsed it
Get content - text(), html() and val()

Three simple and practical jQuery methods for DOM operations:

text() - Settings 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 the form field

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:

Example
Copy code The code is 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