Hi Kris,

The best way is to not use an ID, or to use a class.

Based on the HTML you posted, you could just use this:
$(this).parent().next().show().end().remove();
... which will show the description and remove the "show description" link

EXAMPLE:
<div class="products">
 <div class="product" id="product_1">
   <p>Name: Red Widget</p>
   <p>Price: 22.00</p>
   <p><a href="javascript:;"
onclick="$(this).parent().next().show().end().remove();">Show
description</a></p>
   <p id="description_1" style="display:none;">sadasdas
dasdasd</p>
 </div>

Cheers,
Diego A.


2008/7/4 Kris <[EMAIL PROTECTED]>:

>
> 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