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

dataset vs .data – Difference?

dataset is a native property of an element that contains the data attributes, it’s a new(ish) addition and as such is only supported in IE11+, Chrome 8+, FF 6+ etc. A more cross browser solution would be to get the attribute directly webappData.getAttribute(‘data-rating’); data() is a jQuery method, and other than using the HTML5 data … Read more

JQuery .data() not working?

data doesn’t set data-* attributes. It manages a data cache unrelated to data-* attributes. It initializes from data-* attributes if there are any present, but never writes to them. To write to an attribute, use attr. Example: Updated Fiddle var div = $(“<div />”) $(div).attr(“data-foo”, “bar”) console.log($(div)[0].outerHTML) What you’re seeing is just one of the … Read more

Why does JS code “var a = document.querySelector(‘a[data-a=1]’);” cause error?

From the selectors specification: Attribute values must be CSS identifiers or strings. Identifiers cannot start with a number. Strings must be quoted. 1 is therefore neither a valid identifier nor a string. Use “1” (which is a string) instead. var a = document.querySelector(‘a[data-a=”1″]’);

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