jQuery selector regular expressions

前端 未结 10 2310
傲寒
傲寒 2020-11-21 22:36

I am after documentation on using wildcard or regular expressions (not sure on the exact terminology) with a jQuery selector.

I have looked for this myself but have

10条回答
  •  臣服心动
    2020-11-21 23:10

    You can use the filter function to apply more complicated regex matching.

    Here's an example which would just match the first three divs:

    $('div')
      .filter(function() {
        return this.id.match(/abc+d/);
      })
      .html("Matched!");
    
    
    
    Not matched
    Not matched
    Not matched
    Not matched

提交回复
热议问题