开发者

Absolute selection to relative selection using $(this)

Say there is a selector $("#someID p") and that $(this) = $("#someID"). What selector would always be equal (if it was more complicated, like the example below) starting with $(t开发者_如何学编程his).

Example:

  I have the following selector: $(tableMap.id + " tr:eq(" + i + ") td:eq(" + j + ")")

  On that line, I have $(this) being equal to $(tableMap.id).

  How would I remove tableMap.id from the first line and still keep the rest of the selector?


$(this).find("tr:eq(" + i + ") td:eq(" + j + ")")

or

$("tr:eq(" + i + ") td:eq(" + j + ")", this)

Reference: find(), jQuery()


If you don't wanna use element id, you need to provide full specific selector, take a look at this question: Get CSS path from Dom element

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜