Find all elements based on ids using regex on jQuery selector

后端 未结 5 1028
时光取名叫无心
时光取名叫无心 2020-12-01 07:54

I\'ve got several elements with unique ids like so:

5条回答
  •  不思量自难忘°
    2020-12-01 08:30

    If the id was something like news-top-1, news-top-2, news-top-3, news-top-4 etc. then the selectors would have helped you.

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

    $.each( $("input[name^='news-top-']"), function () {
      alert( $(this).hide() );
    });
    

提交回复
热议问题