Home > Web Front-end > JS Tutorial > body text

js click a tag to get the custom attribute method of a

高洛峰
Release: 2017-01-04 17:31:05
Original
1444 people have browsed it

I encountered a problem on my project today. When I click on the a tag, the complete content needs to be displayed.

Originally I wanted to use jquery’s click method

Haha

In the click method of jquery, assign the ownattr attribute of this to the div tag of the complete content

However This has never worked

After a while of research, I found that the original project framework uses jquery ajax to obtain the background list information. When the page executes the click method, ajax has not been completed

Then I decided to use Basic js

method:

function showDetail(obj){
 
 var ownattr= obj.attributes[ownattr].nodeValue; //自定义属性采用此方式获得
 var id = obj.id; //基本属性可以采用此方式获得
}
Copy after login

The above js method of clicking on the a tag to obtain the custom attribute of a is all the content shared by the editor. I hope it can give you a reference. I also hope that everyone will support the PHP Chinese website.

More js Click the a tag to get the custom attribute method of a. For related articles, please pay attention to the PHP Chinese website!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template