So, I am trying to get a data attribute from an element that is inside an iframe. This iframe is inside our website. So, when I click on the next button I have a callback that has the following code.
onNext : function(){
var $img = $(".tacobowl").contents().find(".url").data('img');
var $imgFolder = $(".tacobowl").contents().find(".url").data('imgFolder');
alert($img + ' ' + $imgFolder);
},
This code returns an alert box that says "undefined undefined".
The class taco
is attached to the <iframe class="taco"></iframe>
Then this is the html inside the iframe.
<div class="url" data-img="small" data-imgFolder="breakfast">
</div>
I have been able to add classes by using the following code. But, I have not been able to get the data attribute from this same div.
$(".tacobowl").contents().find(".url").addClass("taco100");
Is it even possible to get the data attribute in such a way?