-1

my textarea is

var tex = document.createElement("TEXTAREA");
document.body.appendChild(tex);

how can I add class and id to the textarea or areas?

j08691
  • 204,283
  • 31
  • 260
  • 272
  • 1
    Possible duplicate of [JavaScript Adding an ID attribute to another created Element](https://stackoverflow.com/questions/19625646/javascript-adding-an-id-attribute-to-another-created-element) – j08691 Jun 28 '18 at 20:28

1 Answers1

0
var tex = document.createElement("TEXTAREA");
tex.setAttribute("class", "democlass");
tex.setAttribute("id", "demoId");
document.body.appendChild(tex);

for reference https://www.w3schools.com/jsref/met_element_setattribute.asp

Punith Jain
  • 1,647
  • 1
  • 15
  • 21