I have some element that goes like this
<div class="section current" section="Email">
</div>
What i need is to check that section Email have class CURRENT, and do something like
if ($('.section').attr(section == Email).hasClass('current')){
// Do something...
}
I know this is wrong syntax but i want just to simple show what i need?
.attr()method is used for getting or setting an attribute, it's not used for finding an element that matches an attribute. Do you bother to read the documentation of functions before you use them, or do you just pray that they'll do what you want?(section == Email)wouldn't do what you want. That compares a variable namedsectionwith a variable namedEmail, and passes eithertrueorfalseto theattrmethod. That's just basic Javascript syntax, nothing to do with jQuery or selectors.