Jump to content


Photo

specifying variables with jquery


  • Please log in to reply
2 replies to this topic

#1 derek.sullivan

derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 343 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 21 March 2011 - 01:04 PM

What I am looking to do is the show() feature in jquery. In my PHP code, I have the code listing directories and each directory's link I want to have a specific link and a specific <div> tag under it. For instance:

[directory link]
[div tag]

The div tag's id will be the same as the directory name, so when I click the directory link "1" it will show the div "1" under the link. Does that make sense? Now, I know how to show/hide div's in jquery, but how do I call specific variables with it?

#2 derek.sullivan

derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 343 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 21 March 2011 - 03:21 PM

The directory name would also be "1"

#3 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 21 March 2011 - 06:35 PM

I don't know what you mean by variables, but this could easily be accomplished by selecting the next sibling of the link (if there is literally nothing else between the two).

i.e.
$('.directory').click(function (){
    $(this).next().show();
});

p.s. Showing the exact markup would help us give other suggestions :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users