0
Is this code in correct form or Am i doing wrong
var displayresult =document.write("<h1>RESULTS</h1> </br></br>" "<h3>Name:</h3>"+name+"</br></br>""<h3>Class:</h3>"+cls+"</br></br>""<h3>Total marks:</h3>"+total+"</br></br>""<h3>Average:</h3>"+avg+"</br></br>""<h3>Grade:</h3>"+grade+"</br></br>""<h3>results:</h3>"+result+"</br></br>"); document.getElementById("result").innerHTML=displayresult;
4 Answers
+ 2
you dont need to, just put the string in var, then use them with innerHTML
var name = "<h3>"+fullname+"</h3>"
document.getElementById('hello').innerHTML = name;
alternativly instead of
"<h3>"+fullname+"</h3>"
you can use
`<h3> ${fullname} </h3>`
which is easier to read
+ 1
you dont need "" between </br> and <h3>
0
Ok but is it possible to write document. Write and put it in a var
0
Thank you