setAttribute

fun setAttribute(name: String, value: JsonPrimitive, namespace: String? = null): Element

Set an attribute of this element. For example a().setAttribute("href", "http://kweb.io") will create an <a> element and set it to <a href="http://kweb.io/">.

Parameters

namespace

If non-null elements will be created with Element.setAttributeNS() with the specified namespace. If null then Kweb will use Element.createElement.

fun setAttribute(name: String, value: String): Element
fun setAttribute(name: String, value: Boolean): Element
fun setAttribute(name: String, value: Number): Element
fun setAttribute(name: String, oValue: KVal<out JsonPrimitive>): Element

Set an attribute to the value in a KVal, if the value changes the attribute value will be updated automatically.