Jquery: How To Find An Element Which Is Coming 2 Elements Before Current Element
i have a markup which look like this:
Paragraf3-dummytext
Quisque id odio. Praesent venenatis metus at tortor pulvinar var
Solution 1:
paragrafheading.push($(this).parent().prev().text());
paragrafheading.push($(this).closest('> h3').find('> h3').text());
Solution 2:
Solution 3:
paragrafheading.push($(this).parents('p')[0].prevAll('h3')[0].text());
Doing it this way means that even if the structure changes in the future you will still be able to get the first ancestor h3 element regardles of how many paragraphs etc are in the dom tree before the a tag
Post a Comment for "Jquery: How To Find An Element Which Is Coming 2 Elements Before Current Element"