jQuery selector regular expressions

前端 未结 10 2300
傲寒
傲寒 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:20

    If your use of regular expression is limited to test if an attribut start with a certain string, you can use the ^ JQuery selector.

    For example if your want to only select div with id starting with "abc", you can use:

    $("div[id^='abc']")
    

    A lot of very useful selectors to avoid use of regex can be find here: http://api.jquery.com/category/selectors/attribute-selectors/

提交回复
热议问题