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 does jquery remove the attribute of a tag

2025-02-23 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 remove the attribute of a tag", so the editor summarizes the following content, detailed content, 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 remove the attribute of a tag" article.

Two methods: 1, directly use removeAttr () to remove the specified attribute of the a tag, syntax "$(" a "). RemoveAttr (" attribute name to be removed ")". 2. Use the attr () tag to set the value of the specified attribute to empty, and the syntax "$(" a "). Attr (" attribute name to be removed ",") ".

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

Two methods of removing the specified attribute of a tag by jquery

1. Use removeAttr ()

The removeAttr () method removes the specified attribute from the selected element. Syntax:

$("a") .removeAttr ("property name to be removed")

Example: remove the target attribute of the a tag

$(document) .ready (function () {$("button") .bind ("click", function () {$("a") .removeAttr ("target");}) A tag hyperlink

Remove the attribute of the a tag

2. Use attr ()

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

You can also invalidate the specified attribute when you use the attr () method to set the property value of the selected element to null.

Syntax:

$("a") .attr ("property name to be removed", ")

Example: remove the href attribute of the a tag

$(document) .ready (function () {$("button") .bind ("click", function () {$("a") .attr ("href", ");}) A tag hyperlink

Remove the attribute of the a tag

Expand knowledge:

Tags define hyperlinks that are used to link from one page to another.

The most important attribute of an element is the href attribute, which specifies the target of the link.

Attributes that can be set by the label

Property value description is not supported in charsetchar_encodingHTML 5. Not supported in coordscoordinatesHTML 5. The target URL of the hrefURL link. Hreflanglanguage_code specifies the benchmark language of the target URL. Used only if the href property exists. Mediamedia query

Specify the media type of the target URL.

Default value: all. Used only if the href property exists.

Not supported in namesection_nameHTML 5. Rel

Alternate

Archives

Author

Bookmark

Contact

External

First

Help

Icon

Index

Last

License

Next

Nofollow

Noreferrer

Pingback

Prefetch

Prev

Search

Stylesheet

Sidebar

Tag

Up

Specifies the relationship between the current document and the target URL.

Used only if the href property exists.

Not supported in revtextHTML 5. Shape

Default

Rect

Circle

Poly

Not supported in HTML 5. Target

_ blank

_ parent

_ self

_ top

Where to open the target URL. Used only if the href property exists. Typemime_type

Specifies the MIME type of the target URL. Used only if the href property exists.

Note: MIME = Multipurpose Internet Mail Extensions.

The above is about the content of this article on "how jquery removes the attribute of a tag". I believe we all have some 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 pay attention to 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.

Share To

Development

Wechat

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

12
Report