show a div having style="display:none" after passing value to js variable
html, javascript, jsp
Solution
Try:
mydiv.style.display = "block";
instead of
mydiv.style.visibility = "visible";
Problem
Initially the div id =" showHide" is invisible. I want to make it visible when the value of vall is not null. But the code is not working. Though variable vall is getting values, the div is still not visible. What is the problem with js codescript?? I am using jsp. ``` <head> </head> <body> <div id =" showHide" style="display:none"> /*HTML TABLE*/ </div> <script type="text/javascript"> alert("first alert"); var vall = "<%=vall%>"; if (vall != null) { var mydiv = getElementById.("showHide"); mydiv.style.display ="block"; alert("second alert"); <% System.out.println("jsvar="+vall);%> } </script> </body> ``` When I logged in the console i got the error: uncaught syntaxError: unexpected token ( and both the alert box are also not showing.