Hey guys I have a navigation Menu and so on everything works fine. I added a class with font-awesome arrow which toggles when I click on the different menu items. The Menu will be expanded when I click on a specific link, a javascript is comparing the URL. Unfortunately when I click on a link, the menu will be expanded but my class is getting into its default state. I couldn't figure out on which part in the code I have to make this work. I would appreciate any suggestions and hope that there is a solution without cookies or external scripts. As far as I know, when I change the code wheter only the first symbol changes or all symbols are changing but not one specific.
here is a working example on my hoster click here is the page "two.html" clicked and I would like to have the symbol of the arrow on the expanded menu changed to the "up" class (default down)
heres the fiddle (removed code for example)
The html can be seen on the testsite
here is the javascript
$(document).ready( function() {
// initialize accordion
$('#Accordion ul').each( function() {
var currentURI = window.location.href;
var links = $('a', this);
var collapse = true;
for (var i = 0; i < links.size(); i++) {
var elem = links.eq(i);
var href = elem.attr('href');
var hrefLength = href.length;
var compareTo = currentURI.substr(-1*hrefLength);
if (href == compareTo) {
collapse = false;
$(elem).css({ 'background-color': '#a7a9ac', 'color': '#000' });
break;
}
};
if (collapse) {
$(this).hide();
}
});
$("#Accordion").delegate('div', 'click', function() {
$('#Accordion div').removeClass( "up" );
$('#Accordion div').addClass( "down" );
var ul = $(this).next('ul');
if (ul.is(':visible')) {
ul.slideUp(500);
} else {
$('#Accordion ul').not(ul).slideUp(500);
ul.slideDown(500);
var div = $(this)
$( this ).toggleClass( "up" );
}
});
});
and the css
@charset "utf-8";
/* CSS Document */
body {
font: 0.8em "Lucida Sans Unicode", "Lucida Grande", Arial, Helvetica, sans-serif;
color: black;
background: #F8F8FF;
}
body,html {
margin: 0 auto;
padding: 0;
height:100%;
}
h2{margin-left:10px;padding-top:10px;}
p{padding-left:10px;}
body > #wrapper {height: auto; min-height: 100%;}
#wrapper {
width: 990px;
margin: auto;
padding: 0;
height:100%;
border-left:1px solid #a7a9ac;
border-right:1px solid #a7a9ac;
border-bottom:1px solid #a7a9ac;
-webkit-box-shadow: 0px 1px 26px 7px rgba(0,0,0,0.25);
-moz-box-shadow: 0px 1px 26px 7px rgba(0,0,0,0.25);
box-shadow: 0px 1px 26px 7px rgba(0,0,0,0.25);
background: url(inhalt.png) repeat-y center top fixed;
}
#header{
height:100px;
background:#363636;
color:silver;
font: 4em "Lucida Sans Unicode", "Lucida Grande", Arial, Helvetica, sans-serif;
line-height: 120px;
padding: 0 20px;
}
#navi{
float:left;
background:#F8F8FF;
width:199px;
margin: 0;
padding: 0;
height:100%;
}
#text{
float:right;
width:760px;
padding-left:10px;
background:#F8F8FF;
}
#nav2 {list-style: none; padding: 5px 0 5px 0;text-align:center;margin:0;}
#foot a {vertical-align: -moz-middle-with-baseline; text-decoration: none; color:white;text-align:center;}
#foot li a:hover {text-decoration:underline;color:white;text-align:center;}
#foot {
color: white;
text-align: center;
background:#363636;
height:30px;
width:990px;
margin: 0 auto;
border:1px solid #363636;
clear:both;
}
.top{color:black;text-decoration:underline;}
.top:hover{color:red;text-decoration:underline;}
#Accordion,#Accordion ul{
list-style:none;
padding:0;
margin:0;
}
.cssmenu {
list-style: none;
padding: 0;
margin: 0;
font-size: 0.9em;
width:100%;
}
.border{border-bottom:1px solid #a7a9ac;}
.bordertop{border-top:1px solid #a7a9ac;}
.cssmenu li a {
display: block;
padding: 5px 20px;
color: black;
text-decoration: none;
background:#DBDBDB;
}
.cssmenu ul li span{ display: block;
padding: 5px 20px;
background-color: #DBDBDB;
border-top:1px solid #a7a9ac;
cursor:pointer;
color:#000;
}
.cssmenu a:hover {
color: #FFF;
background-color:#363636;
}.cssmenu span:hover {
color: #FFF;
background-color:#363636;
}
.submenu li a {
display: block;
padding: 5px 40px;
color: black;
text-decoration: none;
background:#DBDBDB;
border-top:1px solid #a7a9ac;
}
#test{
}
.down{
}
.down::after {
content: '\f107';
color: black;
font-family: FontAwesome;
position: absolute;
margin-top: -20px;
margin-left: 170px;
}
.up{
}
.up::after {
content: '\f106';
color: black;
font-family: FontAwesome;
position: absolute;
margin-top: -20px;
margin-left: 170px;
}
Thank you in advance