In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "jquery how to modify the title attributes of elements", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "jquery how to modify the title attributes of elements" article.
Modification method: 1, with attr (), you can set the value of the specified attribute of the selected element, syntax "element object .attr (" title "," new value ")", the new value will cover the old value; 2, with prop (), you can specify the attribute value for the set of matching elements, syntax "element object .prop (" title "," new value ")".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
The title attribute of the element
The title attribute specifies additional information about the element.
This information usually displays a tooltip text (tooltip text) when you mouse over the element.
Tip: the title attribute is often used with form and an elements to provide information about the input format and link destination. It is also a required attribute for abbr and acronym elements.
So how do you use jquery to modify the title attribute of an element?
In jquery, you can modify the title property in two ways
Attr ()
Prop ()
1. Use the attr () method to modify the title property
The attr () method sets the value of the specified attribute of the selected element
There are also two grammatical formats:
/ / set a single attribute value $(selector) .attr ("attribute name", "attribute value") / / set one or more attribute values $(selector) .attr ({attribute name: attribute value,...})
If you want to modify the title attribute of an element, you can directly use the first syntax format.
Example:
$(document) .ready (function () {$("button") .click (function () {$("div"). Attr ("title", "new title value");}) This is a test text.
Modify the title attribute of an element
2. Use the prop () method to modify the title property
The prop () method sets or returns the properties and values of the selected element.
When this method is used to return an attribute value, it returns the value of the first matching element.
When this method is used to set attribute values, one or more attribute / value pairs are set for a collection of matching elements.
Syntax:
$(selector) .prop ("property name", "attribute value")
Note: the prop () method should be used to retrieve property values, such as DOM properties such as selectedIndex, tagName, nodeName, nodeType, ownerDocument, defaultChecked, and defaultSelected.
Example:
$(document) .ready (function () {$("button") .click (function () {$("div"). Prop ("title", "new title value");}) This is a test text.
Modify the title attribute of an element
The above is about the content of this article on "how jquery modifies the title attributes of elements". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please 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.