IE上的JavaScript DOM [英] JavaScript DOM on IE
问题描述
我想使一个JS函数切换到可见/隐藏。
var foo = function(n){
var hidden_elements = document.getElementsByName('hidden');
for(var i = 0; i< hidden_elements.length; i ++){
hidden_elements [i] .style.visibility ='hidden';
}
hidden_elements [n] .style.visibility ='visible';
};
它适用于Firefox和Chrome,但不适用于IE。为什么?
提前感谢。
我建议您保存自己的恐怖,并进行:
这些图书馆为顺利浏览不同浏览器的惊喜而做了很多工作。如果您是超级极简主义者,您可以随时查看源他们如何处理差异。另请参阅 quirksmode的兼容性列表。
我知道我没有给出一个坚实的答案,但是你会遇到这些麻烦,所有这些都是一些很好的工具来敲打他们。 p>
I want to make a JS function that switch visible/hidden.
var foo = function(n){
var hidden_elements = document.getElementsByName('hidden');
for(var i=0;i<hidden_elements.length;i++){
hidden_elements[i].style.visibility = 'hidden';
}
hidden_elements[n].style.visibility = 'visible';
};
It works on Firefox and Chrome, but it doesn't on IE. Why? Thanks in advance.
I would recommend saving yourself the horror and going with:
The libraries do a lot to smooth over the surprises of different browsers. If you are being super minimalist you can always check the source for how they are handling the differences. Also have a look at quirksmode's compatibility listing.
I know I didn't give a solid answer but you are going to run into these troubles all the time and these are some good tools for hammering them out.
这篇关于IE上的JavaScript DOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!