Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.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 BS4:使用按钮禁用按钮_Javascript_Jquery_Function_Button_Bootstrap 4 - Fatal编程技术网

Javascript BS4:使用按钮禁用按钮

Javascript BS4:使用按钮禁用按钮,javascript,jquery,function,button,bootstrap-4,Javascript,Jquery,Function,Button,Bootstrap 4,我目前正在为一个我正在开发@work的项目自学BS4。 基本上,我有一个按钮组(2个,左一个是活动的,右一个是禁用的),我想做的是禁用左一个,激活右一个,反之亦然 不要因为JS/jQuery代码而责骂我。我已经知道这是错误的。但是我找不到解决这个问题的方法。您可能需要使用引导中包含的jQuery库 $(document).ready(function() { $('#showscore').click(function() { $('#hidescore').prop(

我目前正在为一个我正在开发@work的项目自学BS4。 基本上,我有一个按钮组(2个,左一个是活动的,右一个是禁用的),我想做的是禁用左一个,激活右一个,反之亦然


不要因为JS/jQuery代码而责骂我。我已经知道这是错误的。但是我找不到解决这个问题的方法。

您可能需要使用引导中包含的jQuery库

$(document).ready(function() {

    $('#showscore').click(function() {
        $('#hidescore').prop('disabled', false);
        $(this).prop('disabled', true);
    });

    $('#hidescore').click(function() {
        $('#showscore').prop('disabled', false);
        $(this).prop('disabled', true);
    });

});

if(x).click(){
这不是编写JavaScript的方式,click事件必须分配给x,但不能在
if
之后使用
click
。其次,您将本机JavaScript与jQuery混合在一起。看起来这里缺少了一个右括号。
function lockbutton() {
    var x = document.getElementById("#showscore").button;
    if(x.click()) {
        document.getElementById("hidescore").disabled = true;
    } else{
        document.getElementById("hidescore").disabled = false; 
    }
}
$(document).ready(function() {

    $('#showscore').click(function() {
        $('#hidescore').prop('disabled', false);
        $(this).prop('disabled', true);
    });

    $('#hidescore').click(function() {
        $('#showscore').prop('disabled', false);
        $(this).prop('disabled', true);
    });

});