English 中文(简体)
频率检查/检查活动触发
原标题:jquery check/uncheck event trigger
  • 时间:2012-05-02 17:21:55
  •  标签:
  • jquery

我有这部法典半途运作。

jQuery( #checkbox ).click(function () {
   jQuery( .cssBox ).animate({height: +=50px }, 500);
   jQuery( #extra ).toggle(this.checked);
});

现在,当检查箱时,盒子就有了扩大,但是当盒子被封不动时,箱子就会变得更大。 我怎么能够加以调整,以便当不加控制时,它回到原来的规模?

最佳回答

问题如下:

jQuery( #checkbox ).click(function () {
   jQuery( .cssBox ).animate({height: ((this.checked)? +=50px : -=50px )}, 500);
   jQuery( #extra ).toggle(this.checked);
});
问题回答

使用<代码>change而不是click (通过和使用空间条码进行其他制片将绕过你的代码)。 另外,根据<条码>条码采用您的计算方法。 国家:

jQuery( #checkbox ).change(function(){
  jQuery( .cssBox ).animate({
    height: this.checked   // is it checked?
      ?  +=50px               // yes, increase by 50px
      :  -=50px               // no, decrease by 50px
  },500);
  jQuery( #extra ).toggle(this.checked);
});
$(function(){
    var isSmall=true;
    $( #checkbox ).click(function () {
        if(isSmall)
        {
           $( .cssBox ).animate({height: +=50px }, 500);
        }
        else            
        {
           $( .cssBox ).animate({height: -=50px }, 500);
        }
       isSmall=!isSmall;
    });        
});​

Sample :





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签