Java HTML Jsoup Element addStyle(Element element, String styleToBeAdded)

Here you can find the source of addStyle(Element element, String styleToBeAdded)

Description

Add style to existing one.

License

LGPL

Parameter

Parameter Description
element - to which style have to be added.
styleToBeAdded - style which will be added.

Declaration

public static void addStyle(Element element, String styleToBeAdded) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class Main {
    /**/*from  w  ww .  j  a  va 2 s .  c  om*/
     * Constants for attribute names.
     */
    public static final String ATTRIBUTE_STYLE = "style";

    /**
     * Add style to existing one.
     * 
     * @param element
     *            - to which style have to be added.
     * @param styleToBeAdded
     *            - style which will be added.
     */
    public static void addStyle(Element element, String styleToBeAdded) {
        String style = element.attr(ATTRIBUTE_STYLE);
        style += styleToBeAdded;
        element.attr(ATTRIBUTE_STYLE, style);
    }

    /**
     * Add style to <code>elements</code>.
     * 
     * @param elements
     *            - list with elements where style have to be added.
     * @param styleToBeAdded
     *            - style which will be added.
     */
    public static void addStyle(Elements elements, String styleToBeAdded) {
        for (Element element : elements) {
            addStyle(element, styleToBeAdded);
        }
    }
}

Related

  1. addAllNodes(Element parent, List childNodes)
  2. addProperty(Map ret, Element element)
  3. addTag(Element e, String tagName)
  4. appendFragment(Element e, String fragment)
  5. appendText(Element element, StringBuffer stringBuffer)
  6. childrenByTag(final Element element, final String tag)