Foros del Web » Programando para Internet » Javascript »

Agrandar caja con un click

Estas en el tema de Agrandar caja con un click en el foro de Javascript en Foros del Web. Hola Necesito saber como puedo agrandar una caja dandole un click Mediante javascript aquí está mi codigo: Html: <html> <head><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...
  #1 (permalink)  
Antiguo 09/02/2011, 13:03
 
Fecha de Ingreso: febrero-2011
Mensajes: 1
Antigüedad: 13 años, 2 meses
Puntos: 0
Agrandar caja con un click

Hola
Necesito saber como puedo agrandar una caja dandole un click
Mediante javascript
aquí está mi codigo:
Html:
<html>
<head><!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>Movimiento Recta</title>
<script type="text/javascript" src="js/cajagrande.js">
</script>
</head>
<body id="body">


<!--<div id="caja1"></div> -->
</body>
</html>


JavaScript:

window.onload=function(){
var x = 20;
var box=document.createElement("div");
box.style.top="50px";
box.style.left="50px";
box.style.width = x+"px";
box.style.height = x+"px";
box.style.backgroundColor = "blue";
box.style.position = "absolute";
document.getElementById("body").appendChild(box);

}

Gracias...
  #2 (permalink)  
Antiguo 09/02/2011, 13:06
Avatar de _cronos2
Colaborador
 
Fecha de Ingreso: junio-2010
Mensajes: 2.062
Antigüedad: 13 años, 11 meses
Puntos: 310
Respuesta: Agrandar caja con un click

Con una caja, ¿te refieres a un div o a un input?
__________________
" Getting older’s not been on my plans
but it’s never late, it’s never late enough for me to stay. "
Cigarettes - Russian Red
  #3 (permalink)  
Antiguo 09/02/2011, 14:14
Avatar de spicke23  
Fecha de Ingreso: septiembre-2005
Mensajes: 17
Antigüedad: 18 años, 7 meses
Puntos: 0
Respuesta: Agrandar caja con un click

Cita:
Iniciado por fherdoiza Ver Mensaje
Hola
Necesito saber como puedo agrandar una caja dandole un click
Mediante javascript
aquí está mi codigo:
Html:
<html>
<head><!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>Movimiento Recta</title>
<script type="text/javascript" src="js/cajagrande.js">
</script>
</head>
<body id="body">


<!--<div id="caja1"></div> -->
</body>
</html>


JavaScript:

window.onload=function(){
var x = 20;
var box=document.createElement("div");
box.style.top="50px";
box.style.left="50px";
box.style.width = x+"px";
box.style.height = x+"px";
box.style.backgroundColor = "blue";
box.style.position = "absolute";
document.getElementById("body").appendChild(box);

}

Gracias...
Que es lo que quieres realmente,por que con eso no entiendo lo que buscas
  #4 (permalink)  
Antiguo 09/02/2011, 15:09
 
Fecha de Ingreso: diciembre-2010
Mensajes: 788
Antigüedad: 13 años, 4 meses
Puntos: 51
Respuesta: Agrandar caja con un click

Te paso tu función modificada:

Código Javascript:
Ver original
  1. window.onload=function(){
  2. var x = 20;
  3. var box=document.createElement("div");
  4. box.style.top="50px";
  5. box.style.left="50px";
  6. box.style.width = x+"px";
  7. box.style.height = x+"px";
  8. box.style.backgroundColor = "blue";
  9. box.style.position = "absolute";
  10. box.addEventListener("click", function(evt){
  11.     this.style.width = '200px';
  12.     this.style.height = '200px';
  13. }, false);
  14. document.body.appendChild(box);
  15. }

Etiquetas: agrandar, aumentar, caja
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:27.