Narendra Manam
Narendra Manam

Reputation: 181

display:none does not work in IE for option tag

display:none is not working in IE, can any one please answer to my question?

If it does not work in IE11, is there any alternative solution?

Here is my code:

<!DOCTYPE html>
<html>
<head>
<style>
    #id1 {
        display:none !important;
        visibility:hidden;
    }
</style>
</head>
<body>
    <select multiple>
        <option id="id1">1</option>
        <option id="id2">2</option>
        <option id="id3">3</option>
        <option id="id4">4</option>
        <option>5</option>
    </select>
</body>
</html>

Upvotes: 2

Views: 9648

Answers (3)

Yang Daniel
Yang Daniel

Reputation: 135

Alternative approach is using disabled="disabled" for option in IE. It's not a perfect solution, but it does another safe way to make option be un-selectable for user

Upvotes: 1

Joe Kdw
Joe Kdw

Reputation: 2261

Basically, IE doesn't support style="display:none;" or Option tag or other relevant used as in mozilla, chrome or safari. Therefore, you can use jquery to hide the Option. in related to the question, you have identical question as in: Options with display:none not hidden in IE

If you wish, single dropdown menu will solve your problem.

Upvotes: 0

Allen Wong
Allen Wong

Reputation: 1433

You cannot do display: none; to <option>, it only works in Firefox. Check this: How to hide a <option> in a <select> menu with CSS?

Upvotes: 0

Related Questions