I think i'm on the right track, my code below works...sort of:
$("a.emailitem").click(function(){ $("div.newsitememail:nth(0)").toggle(); } ); Though, obviously, no mater which "a.emailitem" is clicked - the first newsitememail div is toggled...not exactly what is needed. I tried this: $("a.emailitem").click(function(){ var i = $(this).attr("id"); $("div.newsitememail:nth(i)").toggle(); } ); Which I thought should work, but has no effect. Nothing is toggled. It is as if 'var i' is not passed to nth(). How can I get the var to pass properly? DamianD wrote: > > Hi, > > How do I toggle a div based on the div's value? > > Example: The site I am working on has multiple blog posts per page. > Under each post is a menu. One of the menu items is for emailing the > story. Under this there is a div that will display the email form. This > div is hidden by default. The link is as follows: > > # id ?>">Open Email Interface > > This div is: > > <div class = "newsitememail" value = "<?php echo $stroy->id ?>"> > > My logic so far has been to grab the link's id using jquery and then > display the appropriate div based on the value (which is the same as the > id in the link). > > Here is the jquery code so far: > > $("a.emailitem").click(function(){ > > var id = $(this).attr("id"); > } > > How do I toggle the correct div? > > -- View this message in context: http://www.nabble.com/Toggle-element-based-on-value-tf4009643s15494.html#a11387195 Sent from the JQuery mailing list archive at Nabble.com.