Configurando largura e altura de DIV em JavaScript
eu tenho umdiv
comid="div_register"
. Eu quero definir o seuwidth
dinamicamente em JavaScript.
Eu estou usando este código a seguir:
<code>getElementById('div_register').style.width=500; </code>
mas esta linha de código não está funcionando.
Eu também tentei usar as unidadespx
como o seguinte, ainda sem sorte:
<code>getElementById('div_register').style.width='500px'; </code>
e
<code>getElementById('div_register').style.width='500'; </code>
e
<code>getElementById('div_register').style.width=500px; </code>
mas nenhum deste código está funcionando para mim.
Eu não sei o que está errado.
Eu estou usando o Mozilla Firefox.
EDITAR
<code><html> <head> <title>Untitled</title> <script> function show_update_profile() { document.getElementById('black_fade').style.display='block'; //document.getElementById.('div_register').style.left=((window.innerWidth)-500)/20; document.getElementById('div_register').style.height= "500px"; document.getElementById('div_register').style.width= '500px'; //alert('kutta'); document.getElementById('div_register').style.display='block'; document.getElementById('register_flag').value= 1; document.getElementById('physical_flag').value= 0; document.getElementById('cultural_flag').value= 0; document.getElementById('professional_flag').value= 0; document.getElementById('lifestyle_flag').value= 0; document.getElementById('hobby_flag').value= 0; //alert(window.innerWidth); } </script> <style> .white_content { display:none; } </style> </head> <body> <div id="main"> <input type="button" onclick="javascript:show_update_profile();" id="show" name="show" value="show"/> </div> <div id="div_register"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td> welcome </td> </tr> </table> </div> </body> </html> </code>