jQuery Data vs Attr?

If you are passing data to a DOM element from the server, you should set the data on the element: <a id=”foo” data-foo=”bar” href=”#”>foo!</a> The data can then be accessed using .data() in jQuery: console.log( $(‘#foo’).data(‘foo’) ); //outputs “bar” However when you store data on a DOM node in jQuery using data, the variables are … Read more

jQuery selectors on custom data attributes using HTML5

$(“ul[data-group=’Companies’] li[data-company=’Microsoft’]”) //Get all elements with data-company=”Microsoft” below “Companies” $(“ul[data-group=’Companies’] li:not([data-company=’Microsoft’])”) //get all elements with data-company!=”Microsoft” below “Companies” Look in to jQuery Selectors :contains is a selector here is info on the :contains selector

How can I get the data-id attribute?

To get the contents of the attribute data-id (like in <a data-id=”123″>link</a>) you have to use $(this).attr(“data-id”) // will return the string “123” or .data() (if you use newer jQuery >= 1.4.3) $(this).data(“id”) // will return the number 123 and the part after data- must be lowercase, e.g. data-idNum will not work, but data-idnum will.

Selecting element by data attribute with jQuery

$(‘*[data-customerID=”22″]’); You should be able to omit the *, but if I recall correctly, depending on which jQuery version you’re using, this might give faulty results. Note that for compatibility with the Selectors API (document.querySelector{,all}), the quotes around the attribute value (22) may not be omitted in this case. Also, if you work with data … Read more

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