jQuery selector to target any class name (of multiple present) starting with a prefix?

前端 未结 4 1380
栀梦
栀梦 2020-12-02 19:30

I\'m considering one selection statement that would target one of many css class names in a single class attribute value based on a string prefix.

For example, I wan

4条回答
  •  时光说笑
    2020-12-02 20:13

    You can add your own selectors, in your case you could add a regular expression selector for attributes:

    http://james.padolsey.com/javascript/regex-selector-for-jquery/

    Then you could do something like this:

    $(':regex(class,(^| )detail-)')
    

    http://jsfiddle.net/ambiguous/ArtRS/1/

    I came across that article somewhere on SO but I can't remember where.

提交回复
热议问题