Hi guys, this is the answer to how to pass a variable to a jquery function
and perform an action on a dynamic list.

http://www.learningjquery.com/2006/09/slicker-show-and-hide#comment-60792
http://www.learningjquery.com/2006/09/slicker-show-and-hide#comment-60792 



[EMAIL PROTECTED] wrote:
> 
> 
> HI,
> 
> Thanks for your response, it's a good answer and works in the case you
> describe.
> 
> Unfortunately I've got 2 more <li>'s in between the clicked li and the
> toggled li. The full code looks like this:
> 
> <ul>
>     <li class="evdate">date</li>
>     <ll class="evname"> # name </li>
>     <li class="evregion">Region</li>
>     <li class="evloc">Location</li>
>     <li class="evsum">Event summary to be hidden and displayed</li>
> 
>     <li class="evdate">date</li>
>     <ll class="evname"> # name </li>
>     <li class="evregion">Region</li>
>     <li class="evloc">Location</li>
>     <li class="evsum">Event summary to be hidden and displayed</li>
> 
> </ul>
> 
> Is there a way to say toggle next+2?
> 
> Andy
> 
> On Oct 1, 7:45 pm, MorningZ <[EMAIL PROTECTED]> wrote:
>> So, and if am understanding correctly...  you have this html an are
>> after some sort of accordion like behavior
>>
>> <ul>
>>
>>     <li class="evname">Event 1 Name</li>
>>     <li class="evsum">Summary of Event 1</li>
>>
>>     <li class="evname">Event 2 Name</li>
>>     <li class="evsum">Summary of Event 2</li>
>>
>>     <li class="evname">Event 3 Name</li>
>>     <li class="evsum">Summary of Event 3</li>
>>
>>     <li class="evname">Event 4 Name</li>
>>     <li class="evsum">Summary of Event 4</li>
>>
>>     etc etc..
>> </ul>
>>
>> and you have "evsum" hidden by say:
>>
>> .evsum { display: none; }
>>
>> and you want to click on the "evname" and show the related "evsum"
>>
>> if thats the case, the jQuery could be like:
>>
>> $(document).ready(function() {
>>      $(".evname").click(function() {
>>           $(this).next().toggle();
>>      });
>>
>> });
>>
>> that would show (or hide, hence the use of "toggle") the respective
>> summary
>>
>> On Oct 1, 1:16 pm, andrewsquidge <[EMAIL PROTECTED]> wrote:
>>
>> > Hi guys,
>>
>> > I've been trying to get this literally all day! I just can't work it
>> out.
>>
>> > I've got this HTML:
>> > <ul>
>> > <li class="evname"> 1 This is the event name </li>
>> > <li class="evsum">some text here</li>
>> > </ul>
>>
>> > On click of <li class="evname"> the li beneath should reveal. But
>> because
>> > there are many of these ona page and they will be dynamic I need to set
>> it
>> > to reveal only the relevant one.
>>
>> > So my plan was to reveal the relevant <li class="evsum"> in order.
>> Here's
>> > the jquery:
>>
>> >         $(document).ready(function() {
>>
>> >                 $("li.evname").click(function() {
>> >                         var id = this.id.replace('show_', "");
>> >                         $("#eventlist
>> li.evsum:eq("+id+")").slideToggle();
>> >                 });
>>
>> >         });
>>
>> > But I'm getting nothing. Even when I replace the action (slideToggle)
>> with
>> > an alert(id) I just get an alert saying "This website says:" and no id!
>> I'm
>> > stumped!
>>
>> > PLEASE, please please can someone help me out!
>>
>> > Thanks in advance.
>> > Andy
>> > --
>> > View this message in
>> context:http://www.nabble.com/Passing-a-variable-to-a-function-tp19765153s272...
>> > Sent from the jQuery General Discussion mailing list archive at
>> Nabble.com.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Passing-a-variable-to-a-function-tp19765153s27240p19778198.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to