Home  >  Article  >  Backend Development  >  javascript - I want to get data-status and other data in h4. How should I write it in js code?

javascript - I want to get data-status and other data in h4. How should I write it in js code?

WBOY
WBOYOriginal
2016-12-01 01:27:362002browse

javascript - I want to get data-status and other data in h4. How should I write it in js code?

javascript - I want to get data-status and other data in h4. How should I write it in js code?

Reply content:

javascript - I want to get data-status and other data in h4. How should I write it in js code?

javascript - I want to get data-status and other data in h4. How should I write it in js code?

$('.operation h4').click(function(){}), so there is no need to change it.

There is a problem with your code. Your .operation is a td element, and the this returned by click should also be this element.
Minimal changes should be like this.

<code>$('.operation').click(function(){
    var el = $(this).find('h4');
    console.log(el.attr('data-status'));
});</code>

<code>$(this).find("h4").data("status")</code>
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