Reputation: 13
I have some code for Javascript using jQuery, and I've been wondering how to fix an element of it.
var dataGiven = +$("span.cost-in-usd:first-child").text();
However, the span tag is:
<span class="cost-in-usd" data-se="product-usd-value">42</span>
Is there a way of modifying my code in order for it to recognise data-se
?
Upvotes: 0
Views: 96
Reputation: 391
The following will return the value of attribute
$('.cost-in-usd').attr('data-se');
Upvotes: 0
Reputation: 11375
Yes, use data
.
var datase = $('.cost-in-usd').data('se');
Some links;
Upvotes: 3