HTML form readonly SELECT tag/input

前端 未结 30 3057
陌清茗
陌清茗 2020-11-22 08:28

According to HTML specs, the select tag in HTML doesn\'t have a readonly attribute, only a disabled attribute. So if you want to keep

30条回答
  •  忘掉有多难
    2020-11-22 08:56

    This is the best solution I have found:

    $("#YourSELECTIdHere option:not(:selected)").prop("disabled", true);
    

    The code above disables all other options not selected while keeping the selected option enabled. Doing so the selected option will make it into the post-back data.

提交回复
热议问题