Can jquery get custom attributes?

WBOY
Release: 2022-05-18 16:58:03
Original
2031 people have browsed it

jquery can obtain custom attributes; you can use the attr() method to obtain custom attributes. This method is used to set or return the attribute value of the selected element, including custom attributes. When the parameter only specifies When obtaining the attribute, the specified attribute value will be returned, and the syntax is "element object.attr (custom attribute)".

Can jquery get custom attributes?

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

Can jquery get custom attributes?

attr() method sets or returns the attribute value of the selected element.

According to the different parameters of this method, its working method is also different.

Return the attribute value of the selected element.

Syntax

$(selector).attr(attribute)
Copy after login

attribute specifies the attribute whose value is to be obtained.

Examples are as follows:

Get attributes-attr()

Copy after login

jquery value:

$("#tiny").attr("value");
Copy after login

Get custom attributes

Copy after login

jquery value:

$("#tiny").attr("data_obj");
Copy after login

The example is as follows:

    
Can jquery get custom attributes?
Copy after login

Output result:

Can jquery get custom attributes?

After clicking the button:

Can jquery get custom attributes?

Recommended related video tutorials:jQuery video tutorial

The above is the detailed content of Can jquery get custom attributes?. For more information, please follow other related articles on the PHP Chinese website!

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!