we can assign the input value to a variable and then we’re assingning that variable to an element’s innerHTML, likewise why can’t I insert text object into an element’s innerHTML??
eg code:
x=document.getElementById("my_input"). value;
y=document.createElement("p");
y.innerHTML=x;
This code works but the below code isn’t, why?
eg code:
x=document.getElementById("my_input"). value;
y=document.createElement("p");
z=document.createTextNode("value");
y.innerHTML=z;
Don’t
mistake me ..I’m a beginner in js.. Correct me if I’m wrong..thanks!!