jQuery selector help - how to find element whose ID starts and ends with specific characters

后端 未结 2 1442
-上瘾入骨i
-上瘾入骨i 2021-01-12 02:30

I have a page that\'s created dynamically. It can have a number of different radio buttons with ID\'s like so:



        
相关标签:
2条回答
  • 2021-01-12 02:46

    Well, you were almost there... $('[id^=cc-][id$=1]')

    DEMO:http://jsfiddle.net/pavloschris/nr3ad/

    0 讨论(0)
  • 2021-01-12 02:55

    Filter your selector using the "ends with" selector.

    http://api.jquery.com/attribute-ends-with-selector/

    $('[id^="cc-"]').filter('[id$="idx"');
    

    And make sure to include quotes.

    0 讨论(0)
提交回复
热议问题