Thanks that worked :) Didn't know about that one hehe ;)
Thanks again, Regards Bruno On 21 Jul, 20:14, "Richard D. Worth" <rdwo...@gmail.com> wrote: > var productID = $(this).closest('.item').attr('id'); > > See > > http://docs.jquery.com/Traversing/closest > > - Richard > > On Tue, Jul 21, 2009 at 2:27 PM, Glazz <brunofgas...@live.com.pt> wrote: > > > Hi, > > > I have this HTML: > > > <div id="1" class="item clearfix"> > > > <div class="image"> ...</div> > > <div class="product">x ...</div> > > </div> > > > <div id="2" class="item clearfix"> > > > <div class="image"> ...</div> > > <div class="product">x ...</div> > > </div> > > > In the "product " DIV i have an " x " that x is an image icon, when > > clicked it is suppossed do delete the product, i have it working very > > good, but i don't know if the way i do to get the ID via javascript is > > the best way or is a more simple way to do it. > > > My js to get the ID: > > > var productID = $(this).parent().parent().attr('id'); > > > i have to use parent() twice because i have the " image " div above, > > is there any simple way to get the ID? > > > If i use $('.item').attr('id'); it get's the first ID, so don't > > work... > > > It works very good this way, but i want to change the order of the > > div's i need to change the JS too :S > > > Thanks in advance for any tips ;) > >