jquery - Navigation stay Highlight if in current page -
well problem next, got navigation animation in jquery, green slider comes down when hover < li > tag.
when current page, hightlight state stay down, when mouseout returns top, thats natural behaviour.
i know how can tell jquery "if" $current slide, don't mouseout
maybe u can check out code better in website
i got variable.
$current = current page.
jquery code:
var navhover = function () { $("#s" + this.id).animate({top: '-40px'}, 300, 'swing') $("#a" + this.id).animate({paddingtop: '30px'}, 300, 'swing').animate({paddingtop: '45px'}, 300, 'swing') $("#i" + this.id).animate({top: '-10px'}, 300, 'swing').animate({top: '0px'}, 300, 'swing') } var navrelease = function () { $("#s" + this.id).animate({top: '-130px'}, 300, 'swing'); } $('#navinside .toplevel').hover(navhover, navrelease);
edit: ok, ircmaxell
i add did after css in header can value of currentpage right.
<script type="text/javascript"> var currentpage = "<?php echo substr($current, 1) ?>"; </script>
then change code if statement.
var navrelease = function () { if(this.id != currentpage){ $("#s" + this.id).animate({top: '-130px'}, 300, 'swing');} };
you setting flag in js, like:
var currentpage = "ninicio"
then in navhover:
var navhover = function () { if(this.id != currentpage){ $("#s" + this.id).animate({top: '-40px'}, 300, 'swing') $("#a" + this.id).animate({paddingtop: '30px'}, 300, 'swing').animate({paddingtop: '45px'}, 300, 'swing') $("#i" + this.id).animate({top: '-10px'}, 300, 'swing').animate({top: '0px'}, 300, 'swing') } } var navrelease = function () { if(this.id != currentpage){ $("#s" + this.id).animate({top: '-130px'}, 300, 'swing'); } }
my code might not correct (just typed psudo real quick) should disable hover / release actions if selected id 1 matches page. way stays 'un-animated'.
edit
since having trouble php side of it:
<script> var current = "<?php echo substr($current, 1) ?>"; </script>
edit more...
okay seems having trouble adding
<script> var current = "<?php echo substr($current, 1) ?>"; </script>
in right place. put main body, long on main page right when open <body>
. hope helps, starting feel trying hack not knowing php or javascript.
if answer, please mark 'answer' (green checkmark) thanks..
Comments
Post a Comment