Change custom attribute values

前端 未结 2 675
庸人自扰
庸人自扰 2021-01-29 12:12

I have some code where I\'ve added custom attributes which I want to change the value of.

2条回答
  •  面向向阳花
    2021-01-29 12:38

    Your element isn't custom, it's still a div.

    You can do a custom element like so.

    
    

    Then select like

    $('myCustomElement')...
    

    An alternative is to use data-attributes.

    Then select like so

    var data = $('div').data('myCustomData')//data = 'test'
    

提交回复
热议问题