Hi all. I've been trying to teach myself jquery/javascript and am in the beginning stages still. I had found a great rollover function for jquery online that works perfectly. I was trying to add on to it though and am out of ideas due to my lack of knowledge. Was hoping for a point in the right direction or a fix if you know it.
The code below is very simple to see whats going on. I'm trying to add a function to it that will keep a button in a "selected" state based on what page you are on. The "hover" class that is getting called is what I need to have stay "up/selected".
I was trying to accomplish this by creating a variable called "thisLocation" but the accompanying function isn't working. I thought I could create an "if/else" function that would look for different values and then place the "thisLocation" variable on a few template pages and obviously change their values. Does that make sense?
I'm sure it's a beginners' issue and am really hoping someone can help me. Also, this is just the way I thought would be easiest to make this work, maybe you know something better???
The not working code I wrote starts at "var thisLocation...", everything before it is the function I found and is working perfectly.
Thanks in advance.
Code://<![CDATA[ $(document).ready(function () { //Append a div with hover class to all the LI $('#navBar li').append('<div class="hover"><\/div>'); $('#navBar li').hover( //Mouseover, fadeIn the hidden hover class function() { $(this).children('div').fadeIn('3000'); }, //Mouseout, fadeOut the hover class function() { $(this).children('div').fadeOut('1000'); }) }); var thisLocation = 'pageone'; if (thisLocation == 'pageone') { $(document).getElementsByName('buttonone').append('<div class="hover"><\/div>'); } //]]>


Reply With Quote

Bookmarks