Your current selector $(".error aTitle")
says to match all <aTitle>
elements whose parent element has the CSS class .error
, which isn't quite what you want.
To select the elements you want, you need to change your selector to $('.error.aTitle')
. Every class has to be preceeded by a period (to denote a CSS class), otherwise it'll be seen as an element (ie a <div>
). Spaces between items in a selector indicate heritage, so using a selector like $('.error .aTitle')
means you want to select all elements with a CSS class of .aTitle
whose parent element has the CSS class .error
.
Another, further example of a selector you can use (which may be a bit of overkill) is $('label.aTitle.error')
, which says to select all <label>
with the CSS classes of .aTitle
and .error
. This selector would not match, say, <input type="text" class="error aTitle" />
.