Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys... I would like to ask how do you handle the problem with IE when it comes to enabling and disabling the select option assuming i have this html file

XML
<input type="button" id="target" value="target" />
<select id="sel">
    <option value="">1</option>
    <option value="1">1</option>
    <option value="2">1</option>
    <option value="3">1</option>
</select>


and i have this jquery code
$(document).ready(function(){
		$("#target").click(function(){
			if($("#sel").attr("disabled") == "disabled"){
                           $("#sel").attr("disabled","disabled");
                           $("#sel").prop("disabled",true);
                        }else{
                           $("#sel").removeAttr("disabled","disabled");
                           $("#sel").prop("disabled", false);
                        }
			return false;
		});
		
	});

now this code works in firefox, chrome but when it comes to IE7 I cant seem to enable the select element again once its been disabled... how do i set it to enable again?

help please thanks....
Posted
Comments
Ankur\m/ 18-Jun-12 6:32am    
Why are you using both attr and prop methods? Just keep the prop method and see.
BTW I just copy pasted your code and created an HTML page. but, it doesn't work in any browser.

if($("#sel").attr("disabled") == "disabled")


You should use != in the above if statement. You don't want to set the select to disabled if it is already disabled.

Also,

Instead of

$("#sel").removeAttr("disabled","disabled");


use

$("#sel").removeAttr("disabled");


or

$("#sel").attr("disabled","");
 
Share this answer
 
v2
Try removing - return false from click function block.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900