Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.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
Javascript 选中复选框时使用jquery更改样式表_Javascript_Jquery_Css - Fatal编程技术网

Javascript 选中复选框时使用jquery更改样式表

Javascript 选中复选框时使用jquery更改样式表,javascript,jquery,css,Javascript,Jquery,Css,我有这个密码 <form action="creatPro.php"> <input type="checkbox" name="okk" value="agree" id="okk" onClick="EnableSubmit (this)" />agree <br /> <center> <input type="submit" name="startthis" value="agree" dis

我有这个密码

<form action="creatPro.php">
    <input type="checkbox" name="okk" value="agree" id="okk" onClick="EnableSubmit (this)" />agree
    <br />

    <center>
        <input type="submit" name="startthis" value="agree" disabled id="startthis" class="styled-button-8" />
    </center>
    </fieldset>
</form>
选中
复选框时,应执行以下操作:

  • 启用按钮
    submit
  • 例如,将按钮颜色更改为蓝色
启用时,如何使用
Jquery
更改按钮颜色

这就是我所尝试的

$(document).ready(function(){
  $("input[type=checkbox]").checked(function(){
    $("input[type=submit]").css({"background-color":"blue"});
  });
});  
()

$("#startthis").css( "background-color", "blue" );

使用jQuery,您可以执行以下操作:

$('#okk').change(function () {
    if ($(this).is(':checked')) {
        $('#startthis').css('background-color','blue').prop('disabled', false);

    } else {
        $('#startthis').css('background-color','#ccc').prop('disabled', true);
    }
});

您尚未将
jQuery
添加到
fiddle
中,将其作为库添加到
fiddle
中,并将以下行添加到
启用提交
功能中:

$('#startthis').css('background-color', 'blue');

您可以在css中简单地使用:checked选择器来实现此紫色

#startthis:checked{background-color:blue;}
#startthis{background-color:white;}

是的,我试过了,现在就发布抱歉^^注意更改“color”属性将更改按钮文本的颜色,而更改“background color”属性将更改按钮的颜色。谢谢您的帮助^^
$('#startthis').css('background-color', 'blue');
#startthis:checked{background-color:blue;}
#startthis{background-color:white;}