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

WBOY
Release: 2023-03-02 12:02:02
Original
2043 people have browsed it

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>
Copy after login

<code>$(this).find("h4").data("status")</code>
Copy after login
Related labels:
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