1

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 $(this).

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?

Havvy
  • 1,471
  • 14
  • 27

2 Answers2

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

or

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

Reference: find(), jQuery()

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
0

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

Community
  • 1
  • 1
aularon
  • 11,042
  • 3
  • 36
  • 41