Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/12/2014, 14:08
hernan2212
 
Fecha de Ingreso: marzo-2012
Ubicación: Rosario
Mensajes: 108
Antigüedad: 12 años, 1 mes
Puntos: 0
Pregunta Resaltar texto en pagina + link

Hola, nuevamente pido de su ayuda con un código que modificamos hace unos días.

Estoy usando un script para ir a un sitio dentro de una misma pagina, el problema que cuando me lleva al div al hacer click el link que tengo dentro de esa div se pierde.

Aquí el código:

Código Javascript:
Ver original
  1. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  2. <script>
  3. $(function(){
  4.      $('a[href*=#]').click(function() {
  5.  
  6.        
  7.        
  8.      if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
  9.          && location.hostname == this.hostname) {
  10.  
  11.              var $target = $(this.hash);
  12.  
  13.              $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
  14.             $target.html($("<label>" + $target.text() + "</label>").css("background-color", "yellow"));
  15.              
  16.  
  17.              if ($target.length) {
  18.  
  19.                  var targetOffset = $target.offset().top;
  20.  
  21.                  $('html,body').animate({scrollTop: targetOffset}, 1000);
  22.        
  23.                  return false;
  24.  
  25.             }
  26.  
  27.        }
  28.  
  29.    });
  30.  
  31. });
  32. </script>

Código HTML:
Ver original
  1. <a href="#vaadiv">Ir </a>
  2.  
  3.  
  4.  <div id="vaadiv">
  5. <a href="otrositio.php">Ir a otro sitio</a>
  6.  </div>


Gracias por cualquier ayuda.
Saludos!