- 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);

23rd Sep 2021, 2:20 PM
Даниил Елин
Даниил Елин - avatar
3 Respostas
+ 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); }
23rd Sep 2021, 2:42 PM
Pariket Thakur
Pariket Thakur - avatar
+ 1
Watch your language
23rd Sep 2021, 2:38 PM
Abhay
Abhay - avatar
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.
23rd Sep 2021, 2:40 PM
Abhay
Abhay - avatar