Wykonalem sobie menu na podstawie tego tutoriala:
http://www.republicof3.com/tutorial-how-to...tyle-accordion/
Moje wygląda tak:
http://v5.refbackbank.com/
Wszystko śmiga, ale kiedy chce dodać je do mojej strony muszę umieścić je w diva, i javascript przestaje działać.
Kod:
Kod js:
$(function() { $("a").bind('click',function() { var _this = $(this); // Expand the current link _this.toggleClass('active', 5); _this.next().toggleClass('closed', 500); // Contract the others and set off the 'active' state. $("a").not(_this).each(function() { $(this).next().addClass('closed', 500); $(this).removeClass('active', 5); }); }); });
i kod css:
#account_menu{ width: 195px; background: #FCFCFC; text-align: center; position: absolute; margin-left: 29px; margin-top: -23px; color: #fff } #account_menu a { color: #000; } #account_menu ul { list-style:none; margin:0; padding:0; text-align:left; font-family: Helvetica; } #account_menu > ul{ margin-bottom:200px; border:1px solid #FCFCFC; } #account_menu > ul > li{ position:relative; } #account_menu > ul > li > a{ display:block; outline:0; height:20px; padding:10px; text-decoration:oblivue; font-style: normal; color:#fff; background:#56CA10; border-bottom:1px solid #FCFCFC; font-family:Lato; font-weight:300; -webkit-font-smoothing:antialiased; text-transform:uppercase; font-size:14px; } #account_menu > ul > li > a > i{ display:block; width:45px; height:30px; float:left; } #account_menu > ul > li:nth-child(1) > a > i{ background:url(https://refbackbank.com/img/icon_polaroids.png)no-repeat top left; /*background-size*/ -webkit-background-size:45%; -moz-background-size:45%; -o-background-size:45%; background-size:45%; background-position:5px 3px; } #account_menu > ul > li:nth-child(2) > a > i{ background:url(https://refbackbank.com/img/icon_message.png)no-repeat top left; /*background-size*/ -webkit-background-size:45%; -moz-background-size:45%; -o-background-size:45%; background-size:45%; background-position:5px 3px; } #account_menu > ul > li:nth-child(3) > a > i{ background:url(https://refbackbank.com/img/icon_favorite.png)no-repeat top left; /*background-size*/ -webkit-background-size:45%; -moz-background-size:45%; -o-background-size:45%; background-size:45%; background-position:5px 3px; } #account_menu > ul > li:nth-child(4) > a > i{ background:url(https://refbackbank.com/img/icon_friend.png)no-repeat top left; /*background-size*/ -webkit-background-size:45%; -moz-background-size:45%; -o-background-size:45%; background-size:45%; background-position:5px 3px; } #account_menu > ul > li:nth-child(5) > a > i{ background:url(https://refbackbank.com/img/icon_settings.png)no-repeat top left; /*background-size*/ -webkit-background-size:45%; -moz-background-size:45%; -o-background-size:45%; background-size:45%; background-position:5px 3px; } #account_menu > ul > li:nth-child(6) > a > i{ background:url(https://refbackbank.com/img/icon_history.png)no-repeat top left; /*background-size*/ -webkit-background-size:45%; -moz-background-size:45%; -o-background-size:45%; background-size:45%; background-position:5px 3px; } #account_menu > ul > li > ul{ counter-reset:items; height:auto; overflow:hidden; background:#fff; color:#000; width:100%; } #account_menu > ul > li > ul > li{ counter-increment:items; padding:1em 1.3em; border-bottom:1px solid #DDD; font-size:12px; cursor:pointer; } #account_menu > ul > li > ul > li:hover{ background:#f4F4F4; } #account_menu > ul > li:after{ content:counter(items); font-size:14px; position:absolute; right:10px; top:15px; background:#83D84F; height:30px; padding:5px 20px; margin:-15px -10px; color:white; text-indent:0; text-align:center; line-height:2; } .active{ background:#83D84F; } .closed{ height:0; }
Podejrzewam, że coś jest nie tak w pliku javascript obok toggleclass, ale nie mam pojęcia jak to poprawić, próbowałem tam zmieniać active na account_menu itp. ale niestety nie zadziałało. Dodam, że mam dodane do strony biblioteki jquery i wszelkie jakie tam były podane (w tutorialu).