Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 我的自定义按钮需要添加禁用和启用功能_Jquery - Fatal编程技术网

Jquery 我的自定义按钮需要添加禁用和启用功能

Jquery 我的自定义按钮需要添加禁用和启用功能,jquery,Jquery,我有一个名为“重命名”的自定义按钮。我需要的是,按钮将始终处于禁用状态。当我点击复选框时,按钮将被启用。若选中复选框,则按钮应为启用 <input type="checkbox" name="listcheck"> <input type="checkbox" name="listcheck"> <input type="checkbox" name="listcheck"> <span class="down_btn" id="rename

我有一个名为“重命名”的自定义按钮。我需要的是,按钮将始终处于禁用状态。当我点击复选框时,按钮将被启用。若选中复选框,则按钮应为启用

 <input type="checkbox" name="listcheck">
 <input type="checkbox" name="listcheck">
 <input type="checkbox" name="listcheck">


 <span class="down_btn" id="rename_fun"><a href="#">Rename</a></span>

    .down_btn a {
        background: url("../images/btn_down.png") no-repeat;
        color: #000000;
        display: block;
        height: 20px;
        padding-top: 4px;
        width: 114px;
    }
.down_btn a:hover
{
    width:114px;
    height:20px;
    display:block;
    color:#000;
    background:url(../images/btn_down_over.png) no-repeat;
    padding-top:4px;
}

.向下{
背景:url(“../images/btn_down.png”)不重复;
颜色:#000000;
显示:块;
高度:20px;
垫面:4px;
宽度:114px;
}
.向下_btna:悬停
{
宽度:114px;
高度:20px;
显示:块;
颜色:#000;
背景:url(../images/btn\u down\u over.png)不重复;
垫面:4px;
}
请帮帮我

提前谢谢 Bhavan试试这个

$("input[name=listcheck]").click(function(){

   if(this.checked){
     $("#rename_fun").bind('click.customButton', function(){
        //Click logic here
     });
   }
   else{
     $("#rename_fun").unbind('click.customButton');
   }
});

这是假设您希望“即使选择了一项”按钮处于启用状态,我想这是必需的

$('.listcheck').click(function() { 

$('.listcheck').each(function(){  //iterate over the list to ensure no others are selected

   if($(this).is(':checked'))
   {
      $('#down_button').attr('disabled',false); //if so enable and return
      return false;
   }
   else
      $('#down_button').attr('disabled',true)

   }

}
$('.listcheck').click(function() { 

$('.listcheck').each(function(){  //iterate over the list to ensure no others are selected

   if($(this).is(':checked'))
   {
      $('#down_button').attr('disabled',false); //if so enable and return
      return false;
   }
   else
      $('#down_button').attr('disabled',true)

   }

}