1 Replies - 903 Views - Last Post: 04 September 2009 - 01:38 PM

#1 jnkrois   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 05-March 08

Passing an attribute to a function

Posted 03 September 2009 - 05:47 PM

Hey guys, once again I have a question to ask.
Basically I'm trying to write a jquery function to fadeIn and fadeOut a hidden div.
The idea is to hover over a link and trigger a div to fadeIn and obviously fadeOut on mouseout.
My problem is that I want to use this as a tooltip for many different links and each link would display a different message.
Said that, the function should retrieve the value of "id" of the link that it's being hovered over and pass it to the hidden div so it could be fadedIn and fadedOut.

Please see the HTML
<div class="case_info">
	<a href="#" id="one">1</a>
	<div class="hidden">this is hidden text this is hidden text</div>

Now the Jquery function (at least what I've got so far).
	var grab = $("a").attr("id");

I hope I was able to explain myself here.
Thanks to anyone that can help.

Juan Carlos

Is This A Good Question/Topic? 0
  • +

Replies To: Passing an attribute to a function

#2 Wimpy   User is offline

  • R.I.P. ( Really Intelligent Person, right? )
  • member icon

Reputation: 159
  • View blog
  • Posts: 1,038
  • Joined: 02-May 09

Re: Passing an attribute to a function

Posted 04 September 2009 - 01:38 PM

You should reference "this":
var id = $(this).attr("id");

Hope it helps! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1