How to make a dropdown readonly using jquery?

后端 未结 21 1173
终归单人心
终归单人心 2020-12-02 06:54

I am using the following statement to make it readonly but it is not working.

$(\'#cf_1268591\').attr(\"readonly\", \"readonly\"); 

I don\

21条回答
  •  青春惊慌失措
    2020-12-02 07:34

    There is no such thing as a read-only drop-down. What you could do is reset it to the first value manually after each change.

    $("select").change(function(event) {
        $(this).val($(this).find("option").first().val());
    });
    

    http://jsfiddle.net/4aHcD/

提交回复
热议问题