Skip to content

Instantly share code, notes, and snippets.

@namikuguri
Last active December 28, 2015 14:29
Show Gist options
  • Save namikuguri/7515096 to your computer and use it in GitHub Desktop.
Save namikuguri/7515096 to your computer and use it in GitHub Desktop.
[ select-option-disabled.md ]

選択中、選択できない option に disabled 属性を追加

$(function(){
  $("select").(function(){  
    $(this).children("option").eq(0).attr("disabled","disabled");
  });
});
@mochixx
Copy link

mochixx commented Nov 17, 2013

<script>
$(function(){
    $("select").click(function(){
        $(this).children("option").eq(0).attr("disabled","disabled");
    });
});
</script>
<form>
    <select>
        <option value="">選択してください</option>
        <option value="1">11111</option>
        <option value="2">22222</option>
        <option value="3">33333</option>
    </select>
</form>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment