jQuery each error :Uncaught TypeError: Cannot use 'in' operator to search for '18' in div[data-role=page]

前端 未结 3 1104
离开以前
离开以前 2021-01-18 21:46

My html is like

...
3条回答
  •  鱼传尺愫
    2021-01-18 22:31

    An attribute value must be inside ' '

    Try something like this:

    $.each("div[data-role='page']", function (){
        console.log($(this).attr('id'));
    });
    

提交回复
热议问题