How to make a dropdown readonly using jquery?

后端 未结 21 1122
终归单人心
终归单人心 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:31

    It is an old article, but i want to warn people who will find it. Be careful with disabled attribute with got element by name. Strange but it seems not too work.

    this do not work:

    
    

    this work:

    
    

    Yes, i know that i better should use prop and not attr, but at least now prop will not work because of old version of jquery, and now i cant update it, dont ask why... html difference is only added id: ...

    
    
    
    

    ...

    I have not found any mistakes in the script, and in the version with name, there was no errors in console. But ofcourse it can be my mistake in code

    Seen on: Chrome 26 on Win 7 Pro

    Sorry for bad grammar.

提交回复
热议问题