On this question, how would I make this code unobtrusive?
<select id="x" style="width:200px;"> <option>one</option> <option>two</option> </select> <input type="button" value="Disable" onclick="$('#x').attr('disabled','disabled')"/> <input type="button" value="Enable" onclick="$('#x').removeAttr('disabled')"/>
I tried this:
- <script>
- $(document).ready(function(){
- $("a").click(function(event){
- event.preventDefault();
- $(this).hide("slow");
- });
-
- $('#btn1').onclick(function(){
- alert("button clicked");
- $('#x').attr('disabled','disabled');
- });
-
- $('#btn2').onclick(function(){
- $('#x').removeAttr('disabled');
- });
- });
- </script>
But it doesn't work to disable the drop-down list ('#x'). Thanks!