how do you force a text value in an html 5 data attribute when accessing it in js?
I have a global app with a similar line of html:
<div class="slider" data-max="125" data-cost="10000" data-costtext="10.000">
the ‘.’ in the text cost value is accurate for some languages. When accessing this value through jQuery js
$("div.slider","body").data("costtext")
you will get back 10.
Is a re-write my only option?, like so:
<div class="slider" data-obj='{"max":125,"cost":10000,"costtext":"10.000"}'>
Use
attr("data-x")to access the value and you’ll have aString.jQuery tries to deduce the type and automatically convert it from
Stringwhen you usedata().Source.