Modificar ancho de un div con javascript ....ayuda
Publicado por Gavriel (21 intervenciones) el 10/06/2017 19:19:27


El dìa de hoy tengo una duda ....
_Quiero modificar el ancho (width) de un div , al presionar un botòn . Consegui un còdigo q a primera visa pense q funcionaria , pero no funciona ...
Alguien q me de alguna ayuda

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script language="javascript">
function modificar() {
if (document.getElementById("modificable").style.width == 200) {
document.getElementById("modificable").style.width = 100;
document.getElementById("modificable").style.height = 100;
} else {
document.getElementById("modificable").style.width = 200;
document.getElementById("modificable").style.height = 200;
}
}
</script>
</head>
<body>
<div id="modificable" style="height:200;width:200;background-color:blue">
...
</div>
<input type=button value=pinchar onclick="modificar()"></input>
</body>
</html>
Valora esta pregunta


0