Javascript 隐藏div在IE8中不起作用
这是我的密码。它在chrome和firefox中工作得非常完美,但在ie8中却不行。我有ie10和ie11的测试。它起作用了。。你知道怎么修吗?。。我从这里得到代码:,是不是因为这个标签?。Javascript 隐藏div在IE8中不起作用,javascript,jquery,internet-explorer-8,Javascript,Jquery,Internet Explorer 8,这是我的密码。它在chrome和firefox中工作得非常完美,但在ie8中却不行。我有ie10和ie11的测试。它起作用了。。你知道怎么修吗?。。我从这里得到代码:,是不是因为这个标签?。getElementsByClassName不受IE8支持 <script src="jquery-1.11.2.min.js"></script> <script> function showhide(id){ if (document.getElemen
getElementsByClassName
不受IE8支持
<script src="jquery-1.11.2.min.js"></script>
<script>
function showhide(id){
if (document.getElementById) {
var divid = document.getElementById(id);
var divs = document.getElementsByClassName("hide");
for(var i=0;i<divs.length;i++) {
divs[i].style.display = "none";
}
divid.style.display = "block";
}
return false;
}
</script>
<style>
.bio_image {
display:inline-block;
height:250px;
width:250px;
cursor:pointer;
}
.hide {
display:none;
}
</style>
</head>
<body>
<div onclick="showhide('bill');" class="bio_image"><div class="name">Bill Murray</div></div>
<div onclick="showhide('bill2');" class="bio_image"><div class="name">Bill Murray</div></div>
<div onclick="showhide('bill3');" class="bio_image"><div class="name">Bill Murray</div></div>
<div class="hide" id="bill">BILL</div>
<div class="hide" id="bill2">BILL2</div>
<div class="hide" id="bill3">BILL3</div>
函数showhide(id){
if(document.getElementById){
var divid=document.getElementById(id);
var divs=document.getElementsByClassName(“隐藏”);
对于(var i=0;i在使用jQuery时,可以使用jQuery的.hide()
和.show()
函数。修改函数如下
<script>
function showhide(id){
$('#'+id).show();
$('#'+id).siblings('.hide').hide();
}
</script>
函数showhide(id){
$('#'+id).show();
$('#'+id).hide('.hide').hide();
}
在使用jQuery时,可以使用jQuery的.hide()
和.show()
函数。修改函数如下
<script>
function showhide(id){
$('#'+id).show();
$('#'+id).siblings('.hide').hide();
}
</script>
函数showhide(id){
$('#'+id).show();
$('#'+id).hide('.hide').hide();
}
在使用jQuery时,可以使用jQuery的.hide()
和.show()
函数。修改函数如下
<script>
function showhide(id){
$('#'+id).show();
$('#'+id).siblings('.hide').hide();
}
</script>
函数showhide(id){
$('#'+id).show();
$('#'+id).hide('.hide').hide();
}
在使用jQuery时,可以使用jQuery的.hide()
和.show()
函数。修改函数如下
<script>
function showhide(id){
$('#'+id).show();
$('#'+id).siblings('.hide').hide();
}
</script>
函数showhide(id){
$('#'+id).show();
$('#'+id).hide('.hide').hide();
}
IE8不支持getElementsByClassName方法
您应该使用document.querySelectorAll('.classname')
(适用于IE8+)或实现该功能的库,例如:
jQuery
Moo工具
DOJO
YUI
原型
……除其他外
querySelectorAll
支持:
getElementsByClassName
支持:
IE8不支持getElementsByClassName方法
您应该使用document.querySelectorAll('.classname')
(适用于IE8+)或实现该功能的库,例如:
jQuery
Moo工具
DOJO
YUI
原型
……除其他外
querySelectorAll
支持:
getElementsByClassName
支持:
IE8不支持getElementsByClassName方法
您应该使用document.querySelectorAll('.classname')
(适用于IE8+)或实现该功能的库,例如:
jQuery
Moo工具
DOJO
YUI
原型
……除其他外
querySelectorAll
支持:
getElementsByClassName
支持:
IE8不支持getElementsByClassName方法
您应该使用document.querySelectorAll('.classname')
(适用于IE8+)或实现该功能的库,例如:
jQuery
Moo工具
DOJO
YUI
原型
……除其他外
querySelectorAll
支持:
getElementsByClassName
支持:
更换
function showhide(id){
if (document.getElementById) {
var divid = document.getElementById(id);
var divs = document.getElementsByClassName("hide");
for(var i=0;i<divs.length;i++) {
divs[i].style.display = "none";
}
divid.style.display = "block";
}
return false;
}
替换
function showhide(id){
if (document.getElementById) {
var divid = document.getElementById(id);
var divs = document.getElementsByClassName("hide");
for(var i=0;i<divs.length;i++) {
divs[i].style.display = "none";
}
divid.style.display = "block";
}
return false;
}
替换
function showhide(id){
if (document.getElementById) {
var divid = document.getElementById(id);
var divs = document.getElementsByClassName("hide");
for(var i=0;i<divs.length;i++) {
divs[i].style.display = "none";
}
divid.style.display = "block";
}
return false;
}
替换
function showhide(id){
if (document.getElementById) {
var divid = document.getElementById(id);
var divs = document.getElementsByClassName("hide");
for(var i=0;i<divs.length;i++) {
divs[i].style.display = "none";
}
divid.style.display = "block";
}
return false;
}
是否可以在此脚本上添加鼠标悬停效果?这样,当您将鼠标悬停在图像上时,它也将显示隐藏的div。如果您将鼠标悬停,它将隐藏该div
但是当你点击图像时,它仍然会显示隐藏的div(它现在是如何工作的)
我只想添加在mouseover/mouseout期间显示隐藏div的选项
谢谢。是否可以在此脚本上添加鼠标悬停效果?这样,当您将鼠标悬停在图像上时,它也会显示隐藏的div。如果您将鼠标移出,它会隐藏div
但是当你点击图像时,它仍然会显示隐藏的div(它现在是如何工作的)
我只想添加在mouseover/mouseout期间显示隐藏div的选项
谢谢。是否可以在此脚本上添加鼠标悬停效果?这样,当您将鼠标悬停在图像上时,它也会显示隐藏的div。如果您将鼠标移出,它会隐藏div
但是当你点击图像时,它仍然会显示隐藏的div(它现在是如何工作的)
我只想添加在mouseover/mouseout期间显示隐藏div的选项
谢谢。是否可以在此脚本上添加鼠标悬停效果?这样,当您将鼠标悬停在图像上时,它也会显示隐藏的div。如果您将鼠标移出,它会隐藏div
但是当你点击图像时,它仍然会显示隐藏的div(它现在是如何工作的)
我只想添加在mouseover/mouseout期间显示隐藏div的选项
谢谢。简而言之是
因为GetElementsByCassName
。你知道如何更改我的代码吗?你想让它在ie 8
或ie 7
中工作吗?简而言之是
因为GetElementsByCassName
。你知道如何更改我的代码吗?你想让它在ie 8
或中工作吗e 7
也?简而言之是
因为getElementsByClassName
。你知道如何更改我的代码吗?你想让它也在ie 8
或ie 7
中工作吗