jQuery loop through data() object

后端 未结 6 579
我在风中等你
我在风中等你 2020-12-04 22:28

Is it possible to loop through a data() object?

Suppose this is my code:

$(\'#mydiv\').data(\'bar\',\'lorem\');  
$(\'#mydiv\').data(\'f         


        
6条回答
  •  無奈伤痛
    2020-12-04 22:48

    $.each($.data(this), function(i, e) {
       alert('name='+ i + ' value=' +e);
    });
    

    This will iterate through each property in 'this' element's data object.

提交回复
热议问题