How does that makes it possible to change the table? The solution for all those parents is
var id = curImg.parents('tr').attr('id'); With parents you will get all the parent elements and you can limit it using an expression. http://docs.jquery.com/DOM/Traversing#parents.28_expr_.29 On 5 apr, 14:08, Ronald Haring <[EMAIL PROTECTED]> wrote: > Looks good, only one suggestion, this line: > > var id = > curImg.parent().parent().parent().parent().parent().parent().attr('id'); // > get the id of the parent TR tag > > looks very brittle. If you change the table or tr a bit, then you are > lost. Why dont you try and add another class to the img e.g. class="nav > 1073" and then do something like: > > var curImg = $(this); // store a reference to the image just > clicked upon > var cssClass = curImg.attr("class"); // fetch the classes e.g. "nav 1073" > var idArr = css.split(" "); //split the id > > Regards > Ronald > > Andy Matthews wrote: > > I've made some additions and updates to the code I posted last week: > >http://www.commadelimited.com/uploads/psychic/ > > > I wondered if you all would mind looking over it to see if it can be > > improved. I've got the functionality the way I like it, but you all > > know jQuery way better than I do. So...any suggestions you feel like > > making would be welcomed. > > > Andy Matthews > > Senior Coldfusion Developer > > Office: 877.707.5467 x747 > > Direct: 615.627.9747 > > Fax: 615.467.6249 > > [EMAIL PROTECTED] > >www.dealerskins.com