jQuery - How to add HTML 5 data attributes into the DOM

后端 未结 3 1410
陌清茗
陌清茗 2021-02-19 10:02

I am trying to add a HTML 5 data attribute into the DOM. I have seen on the jQuery site the format for data attributes is:

$(\'.pane-field-related-pages ul\').da         


        
3条回答
  •  迷失自我
    2021-02-19 10:38

    According to the documentation for .data() in the Jquery API, you need to do this to set it:

    $('.pane-field-related-pages ul').data("role", "listview");
    

    And this to check it:

    $('.pane-field-related-pages ul').data("role");
    

提交回复
热议问题