Home > Article > Web Front-end > js click a tag to get the custom attribute method of a
I encountered a problem in 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
0fe27d837666a893b404d829b9ac45eaHaha5db79b134e9f6b82c0b36e0489ee08ed
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 obtains the background list information. When the page executes the click method, ajax has not been completed. Then I decided to use the basic js
method:
function showDetail(obj){ var ownattr= obj.attributes[ownattr].nodeValue; //自定义属性采用此方式获得 var id = obj.id; //基本属性可以采用此方式获得 }