Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/03/2011, 11:51
Avatar de Naahuel
Naahuel
 
Fecha de Ingreso: marzo-2011
Ubicación: localhost
Mensajes: 796
Antigüedad: 13 años, 2 meses
Puntos: 192
Respuesta: Escribir un texto referenciado en un div

Pues yo iría con jQuery. Es muy fácil. Te hice un ejemplo:
Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js'></script>
  5.  
  6. <script type="text/javascript">
  7.     $(document).ready(function(){
  8.         //al hacer click en insertar
  9.         $('#insertar').click(function(){
  10.             var texto = $('#texto-a-insertar').val();
  11.             $('#insertame-texto').html('<p>'+ texto +'</p>');
  12.         });
  13.     });
  14.  
  15.  
  16.  
  17. </head>
  18.  
  19. <label for="texto-a-insertar">Texto a insertar: </label><input id="texto-a-insertar" />
  20. <input type="button" id="insertar" value="insertar texto en div" />
  21.  
  22. <div id="insertame-texto">
  23.  
  24. </div>
  25. </body>
  26. </html>

Acá lo podés ver en funcionamiento:
http://jsbin.com/egini3

La idea es usar el muy útil .html() de jquery. Lo que hace es reemplazar el html interior del elemento que has obtenido con el selector. También podés lograr efectos parecidos con .append(), .after(), .before(). Todas bien documentadas en el sitio de jquery: www.jquery.com