How to disable an element on the page with jQuery or Javascript

This question already has an answer here:

  • Disable/enable an input with jQuery? 11 answers

  • 或者只是使用纯javascript:

    $('img').click(function () {
        document.getElementById("shikh_sec").disabled = true;
    });
    

    假设#shikh_sec是一个可以禁用的输入(不存在禁用的p元素等),你需要prop()

    $('#shikh_sec').prop('disabled', true);
    

    The code is missing a trailing ");"

    A correct version would be something like this

    $('#disable-me').click(function () {
    $(this).attr("disabled", true); // doesn't work :/
    });
    

    JSFiddle: http://jsfiddle.net/5v4mysgt/

    链接地址: http://www.djcxy.com/p/23006.html

    上一篇: 启用和禁用jQuery中的文本字段

    下一篇: 如何用jQuery或Javascript禁用页面上的元素