Here you can find the source of findPreviousHElement(Elements sequence, Element reference)
public static Element findPreviousHElement(Elements sequence, Element reference)
//package com.java2s; //License from project: Open Source License import org.jsoup.nodes.Element; import org.jsoup.select.Elements; public class Main { public static Element findPreviousHElement(Elements sequence, Element reference) { int index = sequence.indexOf(reference); for (index = sequence.indexOf(reference); index >= 0; index--) { Element element = sequence.get(index); if (element.tagName().startsWith("h")) { return element; }//from w ww. ja v a2s . com } return null; } }