简体   繁体   中英

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>

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

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM