HTML5 data-* attribute type casting strings and numbers

Those values are simply strings to vanilla javascript; it’s not attempting any conversion on its own. console.table( […document.querySelectorAll(“a”)] .map(({dataset:{value}}) => ({ type: typeof value, value })) ); <a data-value=”2.0″>2.0</a> <script src=”https://gh-canon.github.io/stack-snippet-console/console.min.js”></script><script>console.config({maximize:true,timeStamps:false})</script><style>.as-console-wrapper{display:block;}</style> <a data-value=”2.5″>2.5</a> jQuery, on the other hand, tries to determine and convert to the appropriate type when accessing data attributes via data(). It’s (arguably) … Read more

jquery get HTML 5 Data Attributes with hyphens and Case Sensitivity

HTML5 allows us to create our own custom attributes to store data. Custom attributes can be called anything we like, like variable names, but they need to be prepended with the word ‘data’, and words are separated by dashes. You could add “foo”, “bar”, and “foo bar” data attributes to an input like this: <input … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)