开发者

Complex jQuery selector

I have hard time figuring out the correct jQuery selector for my problem.

What I have:

1) 11 divs, that has开发者_如何学C class "theCycle", 10 of them are hidden, one displayed 2) There is inputs in the current displayed div element 3) Some inputs have class "required"

What I need:

Need to select class "theCycle", then inputs with class "required" and then check if they are filled.

So far what I have tried fails or still says that my inputs arent filled.


  $(".theCycle:visible input.required").each(function(){
    if ($(this).val() != ""){
       //it's not empty
    } 
  });


$('.theCycle:visible input.required').each(function() {
  if ($(this).val() != '') {
    ...
  }
})

Something like this should work :)


Try with .filter() to get the selector with the desired elements:

var inputs = $("div.theCycle:visible input.required").filter(function(){
     return $(this).val() != ""
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜