views:

26

answers:

2

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?

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

or

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

Reference: find(), jQuery()

Felix Kling
+1 - I think this is what the OP was asking, but the question is really not clear.
Russ Cam
Both work, two answers is really useful too;
Havvy
A: 

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

aularon