@Test public void hasAttr() { Document doc = Jsoup.parse("<p title=foo><p title=bar><p class=foo><p class=bar>"); Elements ps = doc.select("p"); assertTrue(ps.hasAttr("class")); assertFalse(ps.hasAttr("style")); }
public boolean hasAttr(String attributeKey) { for (Element element : this) { if (element.hasAttr(attributeKey)) return true; } return false; }
Elements extends ArrayList<Element> { public boolean hasAttr(String attributeKey) { for (Element element : this) { if (element.hasAttr(attributeKey)) return true; } return false; } }
Elements extends ArrayList<Element> { public boolean hasAttr(String attributeKey) { for (Element element : this) { if (element.hasAttr(attributeKey)) return true; } return false; } Elements();  Elements(int initialCapacity);  Elements(Collection<Element> elements);  Elements(List<Element> elements);  Elements(Element... elements); }
Elements extends ArrayList<Element> { public boolean hasAttr(String attributeKey) { for (Element element : this) { if (element.hasAttr(attributeKey)) return true; } return false; } Elements();  Elements(int initialCapacity);  Elements(Collection<Element> elements);  Elements(List<Element> elements);  Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { public boolean hasAttr(String attributeKey) { for (Element element : this) { if (element.hasAttr(attributeKey)) return true; } return false; } Elements();  Elements(int initialCapacity);  Elements(Collection<Element> elements);  Elements(List<Element> elements);  Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms();  }