我想在同一页面上使用两个javascript滑动菜单,但在其中两个第二个没有工作。我试图以不同方式多次更改<head>
中的代码但问题没有得到解决。
寻求你的帮助。
感谢
<head>
<script type="text/javascript" src="res/sdmenu.js"></script>
<script type="text/javascript">
// <![CDATA[
var myMenu;
window.onload = function() {
myMenu = new cont("1st-sdmenu, 2nd-sdmenu");
myMenu.init();
};
// ]]>
</script>
</head>
<div id="1st-sdmenu" class="cont">
<div class="collapsed">
<span>Bicycles</span>
<a href="#">Product Series</a>
<a href="#">Product Series</a>
</div>
<div class="collapsed">
<span>Electronic</span>
<a href="#">Product Series</a>
<a href="#">Product Series</a>
</div>
</div>
<div id="2nd-sdmenu" class="cont">
<div class="collapsed">
<span>Bicycles</span>
<a href="#">Product Series</a>
<a href="#">Product Series</a>
</div>
<div class="collapsed">
<span>Electronic</span>
<a href="#">Product Series</a>
<a href="#">Product Series</a>
</div>
</div>
答案 0 :(得分:1)
试试这个。它会一次初始化一个。
<script type="text/javascript">
// <![CDATA[
var myMenu1;
var myMenu2;
window.onload = function() {
myMenu1 = new cont("1st-sdmenu");
myMenu1.init();
myMenu2 = new cont("2nd-sdmenu");
myMenu2.init();
};
// ]]>
</script>