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

前端 未结 2 1718
礼貌的吻别
礼貌的吻别 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:38

    There is no shortcut, you may use the attributes collection :

     $(someselector).filter(function(){
          var attrs = this.attributes;
          for (var i=0; i

提交回复
热议问题