jQuery - select all elements with attribute name (not value) beginning with…?

前端 未结 2 1716
礼貌的吻别
礼貌的吻别 2020-12-11 21:06

Say I\'m looking for all elements with an attribute \'data-language\', whose value begins with \'java\' (would match both \'java\' and \'javascript\'). I know how to do this

2条回答
  •  鱼传尺愫
    2020-12-11 21:22

    jQuery has a nice function for this.

    http://api.jquery.com/data/

    $("div").data() // returns all data attributes to this div
    

提交回复
热议问题