Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use jquery attr

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use jquery attr". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use jquery attr.

The function of jquery attr is to set or return the property value of the selected element, and its syntax is "$(selector) .attr (attribute)", where the parameter attribute specifies the property whose value you want to get.

This article operating environment: windows7 system, jquery3.2.1 version, DELL G3 computer

What is the use of jquery attr?

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 property value

Returns the attribute value of the selected element.

Grammar

$(selector) .attr (attribute)

Parameters.

The attribute specifies the attribute whose value you want to get.

Set properties / values

Sets the properties and values of the selected element.

Grammar

$(selector) .attr (attribute,value)

Parameters.

Attribute specifies the name of the attribute.

Value specifies the value of the property.

Use functions to set properties / values

Sets the properties and values of the selected element.

Grammar

$(selector) .attr (attribute,function (index,oldvalue))

Parameters.

Attribute specifies the name of the attribute.

Function (index,oldvalue)

Specifies the function that returns the value of the property.

This function receives and uses the index value and the current property value of the selector.

Set multiple property / value pairs

Set more than one attribute and value for the selected element.

Grammar

$(selector) .attr ({attribute:value, attribute:value...})

Parameters.

Attribute:value specifies one or more attribute / value pairs.

At this point, I believe you have a deeper understanding of "how to use jquery attr". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report