Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML5 hidden attrbibute not working IE11 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hi,

I had read that you can hide select list options cross browser with the hidden attribute and IE11 supports this.

However, I can't get it to work?

Does IE11 support this?

I am using JQuery to apply it..

Code:
$('#position option[value="R"]').attr('hidden','hidden');

I have tried using the property method

Code:
$('#position option[value="R"]').prop('hidden',true);

But that doesn't work either and just adds the hidden attribute with an empty value anyhow?

Any ideas?

Thanks,

1DMF

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Hi 1DMF,
found this on w3schools site

Link

Might be of help, but I am still learning jQuery myself


Steve
Datamasher
 
1DMF said:
However, I can't get it to work?

Does IE11 support this?

Does it work if you add it manually to the source code?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Nope :-(

Code:
<select>
<option>1</option>
<option hidden="hidden">2</option>
<option>3</option>
</select>
IE11 = 1,2,3
FireFox 36 = 1,3
Chrome 40 = 1,3
Opera 27 = 1,3

Looks like contrary to its reported support, it doesn't?

In the end I had to re-factor the entire functionality to physically remove or add the options dynamically using JQuery.

Was a royal pain in the behind as that's the old school (we don't do that anymore) non-HTML5 way of doing it!

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Looks like contrary to its reported support, it doesn't?

Pretty much.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
I am wondering why you want to hide values in an option control.

Because there are multiple selects with a range of possible values that alter dependent on each others selection.

It's nice and easy to simply add or remove either display:none via an applied or removed class or the hidden attribute (one assumes the reason why it was added to the specification).

Hey ho, such is life, nice idea, if it worked cross-browser!

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top