Home  >  Article  >  Web Front-end  >  js click a tag to get the custom attribute method of a

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

高洛峰
高洛峰Original
2017-01-04 17:31:051385browse

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

a69ead37c53301038d46e73bfcf69970Haha5db79b134e9f6b82c0b36e0489ee08ed

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; //基本属性可以采用此方式获得
}

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!


Statement:
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