开发者

Get ID of element that fired the Jquery function

I have a repeater, and each row will show a tool tip, each tool tip will include the row ID , this is my code :

$(document).ready(function () { 
        $('tr.SomeClass').开发者_开发百科qtip({
            content: {
                        text:  // here I want to get the id of the row
            },


You need to use a .each() to loop through the elements here, like this:

$(document).ready(function () { 
  $('tr.SomeClass').each(function() {
    $(this).qtip({
        content: {
          text:  "My ID is: " + this.id
        }
    });
  });
});

With this approach, this refers to each tr.SomeClass element as you go, rather than whatever context you're in (previously document, since you were in a document.ready handler).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜