jQuery filter by an attribute value

后端 未结 3 1178
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-12 11:27
Driver License State Email <
3条回答
  •  遥遥无期
    2021-02-12 12:08

    Not claiming this is any more elegant, but using filter() on a collection allows much more flexibility on what you can match on, and is a little less error prone than string concatenation.

    var matching = $('.selectedColumns a').filter(function(){
                       return $(this).attr('attributeid') == 41
                    });
        matching.prop('selected', true);
    

提交回复
热议问题