How I can add and remove the attribute “readonly”?

前端 未结 4 1278
灰色年华
灰色年华 2021-02-18 20:19
$(document).ready(function() {
  //Check City Value
  var city_value = parseInt($(\"#city\").val());
  if( city_value == 0) {
     $(\"#state\").attr(\"readonly\", true)         


        
4条回答
  •  执念已碎
    2021-02-18 20:48

    While the readonly property takes a boolean value, the readonly attribute takes a string value. You should use the code that you have commented out:

    $("#rate").attr("readonly", "readonly");
    

提交回复
热议问题