Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set value inside div in JS

Tags:

javascript

I have some code that looks like this:

document.getElementById("error").style.display = 'block';

and when this happens I also want to display the error that is supposed to be shown which is stored in another JS variable. How can I add the value of that variable to the div which has id="error"

Thanks!

like image 649
GeekedOut Avatar asked Jun 10 '11 18:06

GeekedOut


1 Answers

var errorMsg = "<p>Example error message</p>"
document.getElementById("error").innerHTML = errorMsg
like image 97
Susam Pal Avatar answered Oct 22 '22 00:10

Susam Pal