Javascript-I want to obtain data such as data-status in h4, how should I write it in js code?

Source: Internet
Author: User
SegmentFault (www. sf. gg) is a leading developer technology community in China. We hope to provide programmers with a pure and high-quality technology exchange platform to learn, communicate and grow with developers and create an era for developers!

Reply content:

$ ('. Operation h4'). click (function () {}), so that it does not need to be changed.

You have a problem with this code, your. OperationIt is a td element, and this element should be returned from the click operation.
The minimum change should be like this.

$ ('. Operation '). click (function () {var el = $ (this ). find ('h4 '); console. log (el. attr ('data-Status '));});

$ (This). find ("h4"). data ("status ")

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.