Jquery find all ids starting with a string?

前端 未结 1 1388
余生分开走
余生分开走 2020-12-02 21:52

Just wondered how I would search for all the ids starting with \"content_\" in the whole page and also a way to only find them in a named div called \"extra_content\". Once

相关标签:
1条回答
  • 2020-12-02 22:24

    Use the attribute-starts-with selector:

    $('[id^="content_"]').hide();
    

    To limit the search to elements within extra_content:

    $('#extra_content [id^="content_"]').hide();
    
    0 讨论(0)
提交回复
热议问题