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

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

高洛峰
Release: 2016-12-06 11:57:39
Original
1366 people have browsed it

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

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

Related labels:
js
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!