jQuery get all ids on page

后端 未结 3 810
甜味超标
甜味超标 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:35

    I think this would work

    var array = [];
    $("*").each(function(){
        if(this.id) array.push(this.id);
    });
    

提交回复
热议问题