Reputation: 1621
I want to use pseudo selectors along with this attribute. How can I use it.
$('input:valid').length
It will return 1 if its valid else 0 for invalid.
the same if I want to achieve using this how can I do that. something like this.
$('input').focusout(function(){
var flag=$('this:valid').length;
console.log(flag);
})
But its not working. Please guide me how to do this.
Upvotes: 0
Views: 67
Reputation: 24638
Try this instead:
var flag=$(this).filter(':valid').length
REF: .filter() | jQuery API Documentation
Upvotes: 2