简体   繁体   中英

two javascript sliding menu on same page not working

i want to use two javascript sliding menu on same page but in both of them second one not working.i have tried to change the code in <head> many time in different ways but problem not getting fix. Looking for your kind help. Thanks

    <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>

Try this. It will initialize one at a time.

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM