1

what's the better/elegant way to do this?

jQuery(this).find('title').next().next().next().eq(0).text(); //THIS WORKS

i tried using

jQuery(this).find('title').eq(3) //DOESN't WORK

but it doesnt...

Francesco
  • 24,839
  • 29
  • 105
  • 152

2 Answers2

8

What about nextAll().eq(2) ? That should be the third item. And append .text() afterwards. If that's not it, can you provide the markup?

meder omuraliev
  • 183,342
  • 71
  • 393
  • 434
1

.eq() is working on the set of matched elements in the chain. So

jQuery(this).find('title').eq(3)

is finding the 4th of a set of elements matching .find('title').

what you probably want is

jQuery(this).find('title').nextAll().eq(2).text()
huntar
  • 1,072
  • 11
  • 9