0

I want to disable a dropdownlist with jQuery code below. In IE 11 the dropdownlist is disabled but in chrome it remains enabled. Any one know of a much more reliable way of getting this to work across browsers?

 if (!userEmail.trim()) {
            $("#DropDownList1").dropdownchecklist("disable");
         }

And below is the definition of the dropdownlist

<div id="divList">
  @Html.DropDownList("DropDownList1", new SelectList(ViewBag.MyList as System.Collections.IEnumerable, "Value", "Text", 0))
</div>
StackTrace
  • 9,190
  • 36
  • 114
  • 202
  • Your question does not mention `dropdownchecklist`, only your code. Is dropdownchecklist a jQuery plugin? – wf4 Apr 10 '15 at 08:19
  • possible duplicate of [Enable/Disable a dropdownbox in jquery](http://stackoverflow.com/questions/7703241/enable-disable-a-dropdownbox-in-jquery) – Rahul Nikate Apr 10 '15 at 08:49
  • Did any of these answers help you at all? – Harko Apr 13 '15 at 22:44

2 Answers2

2

Try:

$("#DropDownList1").prop("disabled", true);

Here's a fiddle too:

http://jsfiddle.net/k5es6na0/1/

Harko
  • 403
  • 4
  • 14
1

you can try

$("#dropDown").attr("disabled", true);

This will work for all browsers

abhi
  • 1,059
  • 9
  • 19