Thank you Dave and Michael!  

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Dave Cardwell
Sent: vendredi 27 avril 2007 11:06
To: jQuery (English)
Subject: [jQuery] Re: test if element as a class


pixeline wrote:
> hi Michael,
> 
> i just did :
> 
> if ($(this).filter(".selected")) {
>                       return true;
>                }
>                else
>                {
> 
> 
> and it worked !
> 

That's not quite right. .filter() returns a jQuery object, which will always
evaluate to true. To use it your way, you'd want to do
if($(this).filter(".selected").length) which will return 0 if there are no
elements, or a positive integer if there are.

Michael was correct in his example of $(this).is(".classname"), which will
return a boolean value as required.


-- 
Best wishes,
Dave Cardwell.

http://davecardwell.co.uk/javascript/jquery/

Ce message Envoi est certifié sans virus connu.
Analyse effectuée par AVG.
Version: 7.5.467 / Base de données virus: 269.6.1/777 - Date: 26/04/2007
15:23
 

Reply via email to