Javascript 删除jquery上的内容

Javascript 删除jquery上的内容,javascript,jquery,Javascript,Jquery,你好,我对javascript和jquery有点陌生,请帮我解决我的问题。我会非常感激的。谢谢大家! 在第7-8页,我如何删除“新游戏”按钮上的“禁用” 使用jquery 以下是index.html: <!DOCTYPE> <html> <head> <link href="assets/css/blackjack.css" type="text/css" media="screen" rel="stylesheet"> <

你好,我对javascript和jquery有点陌生,请帮我解决我的问题。我会非常感激的。谢谢大家!

在第7-8页,我如何删除“新游戏”按钮上的“禁用” 使用jquery

以下是index.html:

 <!DOCTYPE>
<html>
<head>
    <link href="assets/css/blackjack.css" type="text/css" media="screen" rel="stylesheet">
    <script src="assets/js/Modernizr.js"></script>
    <script src="assets/js/jquery.js"></script>
    <script src="assets/js/Mustache.js"></script>
    <script src="assets/js/blackjack.js"></script>

</head>

<body>

    <div class="wrapper">

    <img src="assets/images/rocket-u-logo-large.png">
    <h1>Blackjack</h1>

    <p>Hi, thanks for stopping by our blackjack table. Pull up a chair and let's play...</p>

        <div id="card-table">

            <h2>Dealer</h2>

            <div id="dealer-hand"></div>

            <div id="status"></div>

            <div id="player-hand"></div>

            <h2>Player</h2>

                <div id="player-options">
                    <button class="bj" id="new-game" disabled>New Game</button>
                    <button class="bj" id="hit">Hit</button>
                    <button class="bj" id="stand">Stand</button>

                </div>

        </div>




    </div>


</body>
</html>

21点
嗨,谢谢你来我们的21点桌。拉一把椅子,让我们玩

经销商 玩家 新游戏 打 站
以下是js:

$('#bj').click(function () {
    $('#hit').show();
    $('#stand').show();
});


function initGame() {

    var initErrors = [];
    var errorMessage;

    // Test if browser supports local storage
    if (Modernizr.localstorage) {
        // console.log("Local storage is supported.");
    } else {
        var errorStatus = "Local storage is not available"
        // console.log(errorStatus);
        initErrors.push(errorStatus);
    }

    // Test if browser supports mustache.js
    var mustacheScript = $('script[src*="js/Mustache.js"]').length; 
    if (mustacheScript != 0) {
        // console.log("Mustache loaded!");
    } else {
        var errorStatus2 = "Mustache not loaded."
        // console.log(errorStatus2);
        initErrors.push(errorStatus2);
    }



        function displayErrorMessage() {
        // Test if initErrors array has any errors
            if (initErrors.length != 0) {
                    if (errorStatus2 === undefined) {
                        errorStatus2 = "";
                        } else if (errorStatus === undefined) {
                                   errorStatus = "";
                    } 
            var errorMessage = "Houston, we have a problem (" + errorStatus + ', ' + errorStatus2 + ").";
            // console.log(errorMessage);
            $('#status').append("<p>" + errorMessage + "</p>");
            } else {
            var successMessage = "Ready to play? Click 'New Game' to start...";
            $('#status').append("<p>" + successMessage + "</p>");
            // console.log(successMessage);
            }

        }

        displayErrorMessage();


    //Test 'boolean' return values
    if (initErrors.length != 0) {
        return false;
        $('#new_game').attr("disabled", "disabled");
        } else {
        return true;
        $('#new_game').removeAttr("disabled");
    }


}   


console.log(initGame());

$(document).ready(function () {

    initGame();

});
$('#bj')。单击(函数(){
$('hit').show();
$(“#站”).show();
});
函数initGame(){
var initErrors=[];
var错误消息;
//测试浏览器是否支持本地存储
if(modernizer.localstorage){
//log(“支持本地存储”);
}否则{
var errorStatus=“本地存储不可用”
//控制台日志(错误状态);
initErrors.push(errorStatus);
}
//测试浏览器是否支持mustache.js
var mustacheScript=$('script[src*=“js/Mustache.js”]')。长度;
if(mustacheScript!=0){
//log(“加载了胡子!”);
}否则{
var errorStatus2=“未加载胡子。”
//console.log(errorStatus2);
initErrors.push(errorStatus2);
}
函数displayErrorMessage(){
//测试initErrors数组是否有任何错误
if(initErrors.length!=0){
如果(errorStatus2==未定义){
errorStatus2=“”;
}else if(errorStatus==未定义){
errorStatus=“”;
} 
var errorMessage=“休斯顿,我们有一个问题(“+errorStatus+”,“+errorStatus2+”);
//控制台日志(错误消息);
$(“#状态”)。追加(“”+errorMessage+”

”); }否则{ var successessage=“准备好玩了吗?单击“新游戏”开始…”; $(“#状态”)。追加(“”+成功消息+”

”; //console.log(成功消息); } } displayErrorMessage(); //测试“布尔”返回值 if(initErrors.length!=0){ 返回false; $('new#u game').attr(“disabled”、“disabled”); }否则{ 返回true; $(“#新游戏”).removeAttr(“禁用”); } } log(initGame()); $(文档).ready(函数(){ initGame(); });

看起来您的JS代码有一个错误:在HTML
中,代码是您自己编写的。但它是下面的返回声明,这将使它在可接受的

把返回语句带到下面

$('#new_game').removeAttr("disabled");
它应该可以工作。

您可以尝试以下方法:

$('#new_game').prop('disabled',false);

您可以使用下面列出的任何一种

$('#new_game').attr("disabled", false);


我想你需要的是
$('new#u game').prop(“disabled”,false)
$('#new_game').attr("disabled", false);
$("#new_game").removeAttr("disabled");
$("#new_game").prop("disabled",false);