Uncaught TypeError: Object # has no method 'attr'

后端 未结 2 1768
南方客
南方客 2021-01-03 23:49

Im trying to grab my divs with the class tooltip.

And then do something like this:

var schemes = $(\".tooltip\");

for (var i in schemes) {
    var s         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-04 00:17

    var schemes = $(".tooltip");
    
    schemes.each(function(index, elem) {
        console.log($(elem).attr('cost'));
    });
    

    As a sidenote "cost" is not a valid attribute for any element as far as I know, and you should probably be using data attributes.

提交回复
热议问题