How to get elements by a specific value of a custom attribute in jQuery?

后端 未结 4 1363
天命终不由人
天命终不由人 2021-01-19 16:28

I have a custom attribute called data-role and I\'d like to find all elements where data-role=\"content\" in jQuery.

4条回答
  •  梦谈多话
    2021-01-19 17:03

    Check out jQuery's list of attribute selectors. You're looking for something like

    $('div[data-role="content"]')
    

提交回复
热议问题