Home >Web Front-end >JS Tutorial >js click a tag to get the custom attribute method of a
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!