Reputation: 103
according to Text element document in MDN Value of Attr Node Can be of type Text element.
The Text interface represents the textual content of Element or Attr.
But how can i set value of a DOM element attribute to Text object. Some things like this:
var elm = document.getElementById('myId')
elm.attributes['class'] = new Text('app-class')
In web api documents, value
of Attr is string.
I know attribute can be set by assigning string literal.But i want to set value with Text
node datatype instead of string
datatype
Upvotes: 2
Views: 348
Reputation: 348
You can update your element class via
document.getElementById("myId").className = "app-class";
Upvotes: 1