Foros del Web » Programando para Internet » Javascript »

Ingresar texto al inicio de un div

Estas en el tema de Ingresar texto al inicio de un div en el foro de Javascript en Foros del Web. Hola tengo la siguiente duda tengo un div con text Código: <div id='text'>hola</div> Quiero al inicio del div agregar un <center> y alfinal el </center> ...
  #1 (permalink)  
Antiguo 10/04/2011, 11:55
Avatar de Lautaro_eb  
Fecha de Ingreso: mayo-2010
Ubicación: Bariloche, Argentina
Mensajes: 284
Antigüedad: 13 años, 11 meses
Puntos: 24
Ingresar texto al inicio de un div

Hola tengo la siguiente duda tengo un div con text
Código:
<div id='text'>hola</div>
Quiero al inicio del div agregar un <center> y alfinal el </center> mediante un boton y js...
Muchas gracias ...
  #2 (permalink)  
Antiguo 10/04/2011, 13:10
 
Fecha de Ingreso: marzo-2010
Mensajes: 9
Antigüedad: 14 años, 1 mes
Puntos: 0
Respuesta: Ingresar texto al inicio de un div

mmm no muy te entendi fijate pero intentare ayudarte
segun entendi keras acer que se centre ese texto no?
mmm podrias explicar un poco mas
Código HTML:
Ver original
  1.     <head>
  2.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3.         <title></title>
  4.          <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.2.min.js" type="text/javascript"></script>
  5.         <script>
  6.  
  7.         $(document).ready(function(){
  8.                 $("#boton").click(function(evento){
  9.                 evento.preventDefault();
  10.                 $("#idDiv").slideUp("slow");
  11.                 $("#idDiv").html("<center><h5>Hola</h5></center>");
  12.                 $("#idDiv").slideDown("slow");
  13.             });
  14.        });
  15.  
  16.         </script>
  17.    
  18.     </head>
  19.     <body>
  20.         <h1>Ejemplo</h1>
  21.         <form>
  22.             <input  id="boton" type="submit" value="Centrar"/>
  23.             <div id ="idDiv">Hola</div>
  24.         </form>
  25.     </body>
  26. </html>
  #3 (permalink)  
Antiguo 10/04/2011, 13:12
 
Fecha de Ingreso: marzo-2010
Mensajes: 9
Antigüedad: 14 años, 1 mes
Puntos: 0
Respuesta: Ingresar texto al inicio de un div

Olvide decirte aka lo que ago es centrar al darle el click al boton (puedes correrlo lo hice para ke solo lo peges y le pongas .html), espero te sirva, :)
exitos



Cita:
Iniciado por vidbaz Ver Mensaje
mmm no muy te entendi fijate pero intentare ayudarte
segun entendi keras acer que se centre ese texto no?
mmm podrias explicar un poco mas
Código HTML:
Ver original
  1.     <head>
  2.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3.         <title></title>
  4.          <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.2.min.js" type="text/javascript"></script>
  5.         <script>
  6.  
  7.         $(document).ready(function(){
  8.                 $("#boton").click(function(evento){
  9.                 evento.preventDefault();
  10.                 $("#idDiv").slideUp("slow");
  11.                 $("#idDiv").html("<center><h5>Hola</h5></center>");
  12.                 $("#idDiv").slideDown("slow");
  13.             });
  14.        });
  15.  
  16.         </script>
  17.    
  18.     </head>
  19.     <body>
  20.         <h1>Ejemplo</h1>
  21.         <form>
  22.             <input  id="boton" type="submit" value="Centrar"/>
  23.             <div id ="idDiv">Hola</div>
  24.         </form>
  25.     </body>
  26. </html>

Etiquetas: ingresar, inicio
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 15:19.