开发者

Is there a way to use javascript to determine if the current browser supports hiding <option> tags?

Updated question:

Is there a way to use javascript to feature sniff, rather than the evil, browser sniff, to determine if the current browser supports/doesn't support hiding tags?

IE does not support hiding tags in the select element. So I'd like to write some code to adjust when the browser doesn't support hiding option tags. But I'd rather not write the code based on the browser being IE or not, but rather if the browser supports hiding or not.

Anyone know a way?

Older question:

I wrote some jQuery code to .hide() an <option> element in a select dropdown. .hide() is what I want, because later I can call .show() and the options will not need to be resorted, since the now visible option element will not have changed positions.

开发者_Python百科.hide() worked great in FF/Chrome, but not in IE6/7/8. So my thought was to write more code after the hide which determined if the current browser was capable of hiding the element (rather than writing browser version sniffing code). IE reports that yes, the option element is hidden (even though it isn't).

$('option.hideMe').hide(); var result = $('option.hideMe').is(':visible');

//result === false in IE, but it is still visible in the dropdown.

Before I rewrite the code to either 1) browser sniff or 2) use a different method which includes sorting on all browsers, is there another way of determining this situation?

Edit

The question I am trying to get answered is if is a way to feature sniff, rather than browser sniff, to determine if the current browser supports/doesn't support hiding tags?


For anyone having to deal with hiding option elements in those versions affected, I posted a workaround here which doesn't clone or remove the options but wraps spans around them, which is arguably much easier to deal with:

http://work.arounds.org/issue/96/option-elements-do-not-hide-in-IE/


The only we to hide an option on IE is to remove it from the select list. you cannot hide it or disble it as far i know.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜