Now I use this to create an element
<!-- language: lang-java -->
Document doc = Jsoup.parseBodyFragment("<ol></ol>");
Elements ols=doc.getElementsByTag("ol");
Element ol=ols.get(0);
But this is too complex, because I create many dom in the program, if every use three line to create an element, it is not convenient.
Can I create an element without using the document and elements?
like this:
<!-- language: lang-js -->
var ol=$('<ol></ol>');
Try to use Element
s constructor:
Element el = new Element(Tag.valueOf("ol"), "");
Since version 1.10.2, You can use Element
's constructor like this:
Element el = new Element("ol");
Constructor and Description:
public Element(String tag)
Create a new, standalone element.
Parameters:
tag - tag name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With