Find elements by custom data attribute value

前端 未结 3 454
故里飘歌
故里飘歌 2020-12-22 11:16

I was wondering if there\'s a way to select an item (div,span,whatever..) using javascript with jQuery (+ jQuery UI lib) based on its data attribute value. For example, let\

3条回答
  •  再見小時候
    2020-12-22 11:23

    var resultingElement = $('.b[data-myKey=1234]');
    

    I'm not sure 100% sure, but I think there was an issue with camel-case selectors in data attributes at some point.

提交回复
热议问题