In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
In this article Xiaobian for you to introduce in detail "jquery how to get custom attributes", the content is detailed, the steps are clear, the details are handled properly, I hope this "jquery how to get custom attributes" article can help you solve your doubts, following the editor's ideas slowly in-depth, let's learn new knowledge.
Jquery can get custom attributes; you can use the attr () method to get custom attributes, which are used to set or return the property values of the selected element, including custom attributes. When only the attribute to be obtained is specified in the parameter, the specified attribute value is returned with the syntax of "element object .attr (custom attribute)".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
Can jquery get custom attributes?
The attr () method sets or returns the property value of the selected element.
The working mode of the method is also different according to the different parameters of the method.
Returns the attribute value of the selected element.
Grammar
$(selector) .attr (attribute)
The attribute specifies the attribute whose value you want to get.
Examples are as follows:
Get property-attr ()
Value of jquery:
$("# tiny") .attr ("value")
Get custom properties
Value of jquery:
$("# tiny") .attr ("data_obj")
Examples are as follows:
$(document) .ready (function () {$("button") .click (function () {alert ($("img"). Attr ("city"));})
Returns the width of the image
Output result:
After clicking the button:
After reading this, the article "how to get custom attributes in jquery" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.