我创建了一个包含多个 div 的页面,我想切换到同一个地方。这在 chrome 和 firefox 中运行良好,但在 Internet Explorer 中却没有。我在一个页面上使用了相同的方法,它工作正常,但是当我在另一个页面上复制它以使用多个 div 时它会中断。
jQuery是:
<script type="text/javascript">
$(document).ready(function(){
//Hide the box
$("#sub1").hide();
//Sets up the click function and speed
$("#btn-slide").click(function(){
$("#sub1").slideToggle("slow",function(){
//Toggles link text between open and close
//=="Open" or as changed here to "VIEW DR. MARTENS HISTORY" is vital in order to close the box
($("#btn-slide").html()=="| THE PUNK SCENE |")?$("#btn-slide").html("Close"):$("#btn-slide").html("| THE PUNK SCENE |");
});
return false;
});
</script>
这是在我的头标签中,我已经复制了 3 次,所以它总共在 4 个 div 上工作。我已将 #btn-slide 更改为 #btn-slide1 等。
html是:
<div id="move"><a href="#" title="| THE PUNK SCENE |" id="btn-slide" >| THE PUNK SCENE |</a></div>
这是单击以打开隐藏 div 的链接。同样,我有更多具有不同 div id 的这些 div 调用不同的#btn-slide。
这是正在打开的 div 的 html:
<div id="sub1"><strong>The Punk scene</strong> -and 2nd Generation Skins<br />
<br />
Following the Skins the Punk scene was a well known youth subculture to wear Dr. Martens. When Punk became known in the late 70's a second generation of Skins derived from the Punk scene. The media have often portrayed the 2nd gen Skin over the years, with the popular opinion of Skinhead culture being a 14 hole Dr. Marten (and white laces wearing) aggressive young white male. Fascist parties sourced new recruits from football games and amongst a violent throng of spectators some new recruits were Skins. <br />
</div>
我希望这是有道理的,任何人都对如何使其与 IE 兼容有任何想法。我在 IE 上使用了 f12 工具,但没有错误。