Hi Karl,

Of course, you're right. Javascript should be kept separate from the HTML.

Cheers,
Diego A.

2008/7/4 Karl Swedberg <[EMAIL PROTECTED]>:

>
> Hi Kris,
>
> I'd give the "show description" links a common class -- for example,
> "show-description"  That way you can use a basic selector to apply to all of
> those links.
>
> Then, I'd use the "this" keyword to find the appropriate description
> relative to the clicked link.
>
> Adding "return false" will prevent the link's default event from being
> triggered.
>
> So, given your markup, it might look like this:
>
> $('a.show-description').click(functino() {
>        $(this).parent().next().show();
>        return false;
> });
>
>
> --Karl
> ____________
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
>
>
>
>
>
> On Jul 4, 2008, at 10:36 AM, Kris wrote:
>
>
>> Whats the best way to provide functionality (eg. toggle an 'additional
>> information' div) when dealing with records with unique id's.
>>
>> For example lets say we are dealing with product records each one has
>> a unique id which is a number, so the HTML might look something like
>> this:
>>
>> <div class="products">
>>  <div class="product" id="product_1">
>>   <p>Name: Red Widget</p>
>>   <p>Price: 22.00</p>
>>   <p><a href="">Show description</a></p>
>>   <p id="description_1" style="display:none;">sadasdasdasdasd</p>
>>  </div>
>>
>>  <div class="product" id="product_2">
>>   <p>Name: Blue Widget</p>
>>   <p>Price: 24.00</p>
>>   <p><a href="">Show description</a></p>
>>   <p id="description_2" style="display:none;">sadasdasdasdasd</p>
>>  </div>
>>
>> etc. etc.
>> </div>
>>
>> I want to place unobtrusive jquery that will allow the 'show
>> description' link to display the correct description div...
>>
>> Many thanks, K.
>>
>>
>>
>


-- 
Cheers,
Diego A.

Reply via email to