jQuery get all ids on page

后端 未结 3 813
甜味超标
甜味超标 2021-02-20 08:10

Is it possible to get an array consisting of all id\'s on a page with jQuery?

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-20 08:45

    var ids = $('*[id]').map(function() {
        return this.id;
    }).get();
    

    The .map() method is particularly useful for getting or setting the value of a collection of elements.

    http://api.jquery.com/map/

提交回复
热议问题