开发者

Get ID of element that fired the Jquery function

开发者 https://www.devze.com 2023-01-29 21:30 出处:网络
I have a repeater, and each row will show a tool tip, each tool tip will include the row ID , this is my code :

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

精彩评论

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