tags:

views:

41

answers:

2

Hi everyone,

I have the jQuery qtip() function in my asp.net page and I need to get the id from the clicked item. Does anyone know how to do it?

As an example, please find below my script code...

$("#content a.toolTip").qtip({
     content: { url: 'PageView.aspx?Param=' + '---get id---'  }
)};

Thanks in advance.

[]'rpg

A: 

$("#content a.toolTip").qtip({

content: { url: 'PageView.aspx?Param=' + $( this ).attr( 'id' ) }

)};

ovais.tariq
Thanks for the fast answer but I've done this before and it didn't seem to work. I only got an "undefined" string from javascript.
Here the `this` keyword is most likely referring to the `document` context instead of the actual element. :o)
patrick dw
+2  A: 

If you want to reference the element via this when setting up the qtip, you could do your setup inside of an .each(). That way this refers to the current element.

$("#content a.toolTip").each(function() {
        // Now "this" is a reference to the
        //    element getting the qtip
        // Get the ID attribte -------------------------------v
    $(this).qtip({ content: { url: 'PageView.aspx?Param=' + this.id } });
});
patrick dw
thats the correct way
ovais.tariq
It worked perfectly! Thanks!
@user - You're welcome. :o)
patrick dw