Answer the question
In order to leave comments, you need to log in
How to pass/get the data attribute in the following situation?
Friends, tell me how to pass the data-rat attribute in this case:
<div class='dop' data-rat='8.50'></div>
$('div.dop').myRat({'tekr': $(this).data('rat') }); - не передается в функцию
$('div.dop').myRat({'tekr': 888 }); - передается
Answer the question
In order to leave comments, you need to log in
Because this at the time of code execution is unlikely to point to div.pop.
var $pop = $('div.dop');
$pop.myRat({'tekr': $pop.data('rat') });
Your this link is completely wrong, and $.fn.data has a different purpose than getting data attributes. Read the feature documentation before using it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question