I'm really new to JS and jQuery, but I try adding a class "hide" to an element if it has a data attribute with a specific string. So if "class" hat a data-rating attribute of "0.0", the class "hide" should be added. It doesn't work and I don't know why.
$(document).ready(function() {
if ($(".class").data('rating') === ('0.0')){
$(".class").addClass('hide');
}
});
.classelement. It's likely that the value has been converted to an int or float. You may also need a loop if there are multiple elements with that class('0.0')to begin with? Do they really think text literals would “feel naked” or “freeze to death”, if they don’t blanket them in braces …?)datais NOT an accessor fordata-*attributes. It's both more and less than that."