Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/02/2010, 05:39
Dany_s
 
Fecha de Ingreso: diciembre-2009
Ubicación: Misiones
Mensajes: 867
Antigüedad: 14 años, 5 meses
Puntos: 65
Respuesta: Jquery - ¿Como puedo poner enlaces a un texto?

paso que ahi te devuelve el párrafo y no el texto

tenes que buscar con el método "replace" de javascript que recibe el texto a buscar y el texto a a reemplazar

Código HTML:
<html>
<head>
<meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">
<title>Untitled</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="jquery.color.js"></script>
<script type="text/javascript">

$(document).ready(function(){

    buscar = 'jquery';
    texto = $('p').text();
    texto = texto.replace(buscar, '<a href="http://jquery.com">'+buscar+'</a>');
    $('p').html(texto);

});

</script>
</head>
<body>
<p>Buenas,

Necesito con jquery buscar en los parrafos de un texto una palabra en concreto y envolverla con un enlace.

¿Alguien podría ayudarme?

Gracias</p>
</body>
</html>