Hey Guys,
I am pretty new to Javascript and jQuery and getting a little confused with "Selectors". Now I am sure you are all gurus and will find this trivial, so hoping you can help.
I have this HTML:
<div class="class0">
<div class="class1">
<div class="class2">
<div class="class3">Field 1:</div>
<label class="class4">
<input name="field" type="text" class="class5" />
</label>
I am trying to addClasses to a number of elements but am getting stuck. I am trying to:
jQuery('.class0 input')
.focus(function() {
jQuery(this).parents('.class1').addClass("special_class");
jQuery(this).parents('.class3').addClass("special_class_1");
jQuery(this).parents('.class5').addClass("special_class_2");
But it doesn't seem to work - Class 1 does but the rest dont ? If anyone can help out would really appreciate it!
Thanks