Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-14-2011, 08:40 PM   PM User | #1
kao
New Coder

 
Join Date: Jan 2010
Posts: 18
Thanks: 4
Thanked 2 Times in 2 Posts
kao is an unknown quantity at this point
Can't get the "else" part of a satement to work

So i have a navigation area with tabs of to the side im changing their z-index
so its pops out when hovered on. the first part works fine it pops out.

but i cannot seam to figure out how to get it to revert back to its default level.
Code:
      <script type="text/javascript">
      var value = parseInt($("#aa1").css("z-index"))
      var value2 = parseInt($("#aa1").css("z-index"))

      
      $("#aa1").hover(function() {
      if (value == value2) {
         $(this).css({'z-index' : (value + 22), 'font-weight' : 'bolder'});
        }
        
        else 
        { $(this).css({'z-index' : (value), 'font-weight' : 'normal'}) }
        });
      
      
      
      </script>
the button titled What is the working example
live example is here http://dev.f-k-n.net/dmtm/gnav.html


Thanks for looking.

Last edited by kao; 07-14-2011 at 08:44 PM..
kao is offline   Reply With Quote
Old 07-14-2011, 09:24 PM   PM User | #2
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,817
Thanks: 9
Thanked 681 Times in 675 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
jQuery hover() can take two arguments, which allows you to run a function on mouseenter and another on mouseleave . Assuming you want to revert on mouseout then try:

Code:
      <script type="text/javascript">
      var value = parseInt($("#aa1").css("z-index"))

     $("#aa1").hover(function() {
               $(this).css({'z-index' : (value + 22), 'font-weight' : 'bolder'});//function on mouseenter
      },function(){
	       $(this).css({'z-index' : (value), 'font-weight' : 'normal'});//function on mouseleave
      });
      
      
       </script>
SB65 is offline   Reply With Quote
Users who have thanked SB65 for this post:
kao (07-14-2011)
Old 07-14-2011, 09:55 PM   PM User | #3
kao
New Coder

 
Join Date: Jan 2010
Posts: 18
Thanks: 4
Thanked 2 Times in 2 Posts
kao is an unknown quantity at this point
Awesome thanks, SB65. That worked like a charm.

Also, I am glad also that you told me that it supports 2 Arguments.
I am new to learning jquery and still haven't reached the apex of its learning curve.
kao is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:51 PM.


Advertisement
Log in to turn off these ads.