disable input field totally

This question already has an answer here:

  • Disable/enable an input with jQuery? 11 answers

  • you can set the disabled attribute on the input..

    something like:

        function disablepaid(){
            $(".paid").on("click", function(){
                alert("Do disabling stuff now");
                $(this).prop('disabled', true);
            });
        }
    

    If at any time you need to renable it then:

        $(".paid").prop('disabled', false);
    

    Update

    Also, rather than allowing the user to click on the paid input field and THEN disabling it, why not disable it when you set the zero amount?


    只需使用prop()并将disabled属性设置为true

    $(".paid").on("click", function(){
            $(this).prop('disabled', true);
    
            // or  
            this.disabled = true; 
    });
    

    你可以禁用你的输入

    $(".paid").attr("disabled", "disabled");
    
    链接地址: http://www.djcxy.com/p/23010.html

    上一篇: 只读属性无法禁用使用jquery

    下一篇: 完全禁用输入栏