开发者

fadeIn a div or form depends on click in a form

I use a form where elements hide or show depends on click in the checkbox, it's working fine

http://jsfiddle.net/QEG5a/9/

Now I'll try to fade in another div/form if one of the checkboxes are checked, but nothing happened, does anyone know why?

$('input:checkbox','.checkbox_container').click(function() {
   var checked = $(this).prop('checked');
   $.each($(this).data("connect").toString().split(","), function(index, value) { 
   var item = '#开发者_JS百科item'+value;
   (checked) ? $(item)
       .fadeOut()
       .find("input:checked")
       .removeAttr("checked")
   : $(item).fadeIn()  ;
   if (value == 1){
       $('#myform')
         .html(item) //just for any output
         .fadeIn(); 
  }
});
});

Thank's a lot

Pit


You have to use class selector (.className), not id (#id):

if (value == 1){
    $('.myform')
        .html(item) //just for any output
        .fadeIn(); 
}


Your selector is incorrect and style for your div for the fadeIn effect.

Style:

<div class='myform' style="display:none"></div>

Selector:

$('.myform')

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜