Results 1 to 7 of 7
Thread: jQuery: hasClass/length
Mar 26, 2012, 18:22 #1
OK, this has to be something completely simple that I'm overlooking. I have a callback function for .getJSON, and it applies a certain class ("error") if it finds an error when looping through the JSON output (an associative array). Everything works great, the class is applied, and I can see the resulting style changes. However, after the function I check to see if any elements in the document have the "error" class assigned to them, and none do. I tried:
$('.error').length and also $('input').hasClass('error'), and in both cases the result is 0 (zero)/false. Why doesn't this work? And is there a better way I should be trying to do this? Thanks for any help!