Vasanth Narayanan
Vasanth Narayanan

Reputation: 13

display: none is not working in ie alone it works in ff and chrome

hey dudes recently i came across a bizzare problem while trying to learn tabbing .. my code worked like charm in firefox and chrome it didn't work in any version of ie ...There will be two tabs and related contents when i click on tab1 corresponding content should be shown hiding other one ..same goes for tab2 it worked in ff and chrome .. but ie add all contents as i switch to other tabs my code goes like this http://jsfiddle.net/myth/PZZ6a/16/

Upvotes: 0

Views: 462

Answers (2)

Michael
Michael

Reputation: 763

It definitely has to do with getElementsByName not working with the div element in IE. Easy fix though since you already have classes on those two things, use getElementsByClassName.

var tabs = document.getElementsByClassName("tab");
var seltabs= document.getElementsByClassName("seltab");

Working Fiddle: http://jsfiddle.net/CeVa9/1/

Note: Tested in IE9.

Upvotes: 0

Pointy
Pointy

Reputation: 413712

The calls to "getElementsByName" aren't working for you. I think that's because "name" is not a proper attribute for <a> elements, but I have not found any MSDN documentation supporting that notion. The behavior, however, very strongly suggests that that's the case.

edit — well no, it doesn't seem that "name" is improper for <a> elements after all; however, for whatever reason that's the cause of your problems. The calls to "getElementsByName" are returning empty node lists, so your "for" loops don't do anything.

Upvotes: 1

Related Questions