In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to use the attr method in javascript". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use the attr method in javascript" can help you solve the problem.
In JavaScript, attr is a property manipulation method that sets or returns the property value of the selected element, with the syntax of "$(selector) .attr (attribute)" or "$(selector) .attr (attribute,value)".
The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.
What does attr mean in javascript
The attr () method sets or returns the property value of the selected element.
Returns the attribute value of the selected element.
Grammar
$(selector) .attr (attribute)
The attribute specifies the attribute whose value you want to get.
Sets the properties and values of the selected element.
Grammar
$(selector) .attr (attribute,value)
Attribute specifies the name of the attribute.
Value specifies the value of the property.
Sets the properties and values of the selected element.
$(selector) .attr (attribute,function (index,oldvalue))
Attribute specifies the name of the attribute.
Function (index,oldvalue) specifies a function that returns the value of an attribute.
This function receives and uses the index value and the current property value of the selector.
Set more than one attribute and value for the selected element.
Grammar
$(selector) .attr ({attribute:value, attribute:value...})
Attribute:value specifies one or more attribute / value pairs.
Examples are as follows:
$(document) .ready (function () {$("button") .click (function () {$("img"). Attr ("width", function (nmae v) {return VML 50;});})
Reduce the width of the image by 50 pixels
Output result:
After clicking the button:
This is the end of the introduction to "how to use the attr method in javascript". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.