public String setAttr ( String content , String selector , String attributeKey , String value ) { Element body = parseContent ( content ) ; List < Element > elements = body . select ( selector ) ; if ( elements . size ( ) > 0 ) { for ( Element element : elements ) { element . attr ( attributeKey , value ) ; } return body . html ( ) ; } else { // nothing to update return content ; } }
Sets attribute to the given value on elements in HTML .