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

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

My html is like

...
3条回答
  •  余生分开走
    2021-01-18 22:11

    The key reason your code isn't working is because you're trying to iterate a string, which isn't what you really want to do.

    To iterate jQuery collections, try the other form of .each():

    $("div[data-role=page]").each(function() {
        //...
    });
    

    $.each() is (usually) for arrays or plain objects.

提交回复
热议问题