Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Find - Visible only

Tags:

jquery

I want to check if the div contains a children with class "error" but with the condition that the error class display is not equal to none. (Meaning error class must be visible.

How can change my code below:

 $(".related_field").each(function(){
     var $widthAdj = $(this).find(".autoDiv");
     if($(this).find(".error").length == 0){  //MUST BE VISIBLE "ERROR" CLASS ONLY
        $widthAdj.css("height","48px");
     } else {
        $widthAdj.css("height","63px");
     }
 });
like image 549
newbie Avatar asked Mar 27 '13 09:03

newbie


1 Answers

You mean like this? Using the :visible selector:

if($(this).find(".error:visible").length == 0)
    $widthAdj.css("height","48px");
} else {
    $widthAdj.css("height","63px");
}
like image 104
mattytommo Avatar answered Oct 17 '22 05:10

mattytommo