Possible Duplicate:
jQuery .hasClass() vs .is()
HTML code:
<div class="results">
<div class="table">
<form class="tr" action="#" method="post">
<div class="td">
<input class="datepicker" type="text">
</div>
<div class="td">
<input class="datepicker" type="text">
</div>
<div class="td">
<input type="text">
</div>
</form>
</div>
</div>
JS code:
$('.results').find('input:text').each(function(){
var element = $(this);
var b = element.hasClass('.datepicker');
var c = element.is('.datepicker');
}
My question:
'is' and 'hasClass' is supposed to both return true when it finds an element containing the class "datepicker", correct?
Somehow, it's not. 'hasClass' returns false, and 'is' returns true.
Also, I've been digging for a solution to do some chaining jquery calls. But both 'hasClass' and 'is' returns a boolean only. Is there a JQuery function that returns a $(Jquery) element so I can do something like this? I already tried "filter" function, but seems to not work.
element.SomeFunctionToDigUpAnElementWithClass('datepicker').DoSomeCoolStuff();
================================================================