سؤال

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...

هل كانت مفيدة؟

المحلول

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?

نصائح أخرى

.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()
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top