- 3
create new node in DOM
Hey,i really don't understand why it doesen't work, thank you in advance let tempSel=document.createElement("select"); tempSel.classList.add("form-control"); tempSel.size=1; tempSel.name='fuck'; let option = document.createElement("option"); option.value = "0"; option.text("="); tempSel.appendChild(option); document.body.appendChild(tempSel);
3 Respuestas
+ 2
Mistakes
1. Try to write whole thing inside
window.onload=()=>{
//Your code
}
2. Use innerText instead of text()
option.innerText = "=" ;
3. to use .text it should be .text = "=" instead of .text()
code :
window.onload=()=>{
let tempSel=document.createElement("select");
tempSel.classList.add("form-control");
tempSel.size=1;
tempSel.name='f**k';
let option = document.createElement("option");
option.value = "0";
option.innerText = "=";
tempSel.appendChild(option);
document.body.append(tempSel);
}
+ 1
Watch your language
0
It says text is not a function. Probably you should search a bit about what properties are available option element.
You just can't add any property or function and expect it work.