Hola, estoy haciendo my web y estoy usando un script que utiliza jquery para hacer una navegación por anclas flotante.
El script es el siguiente:
Código PHP:
<script type="text/javascript">
$(function(){
$('a[href*=#]').click(function() {
if (location.pathname.replace(/^//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, 2000);
return false;
}
}
});
});
</script>
Y funciona correctamnte.
El rpoblema viene cuando tengo un slide de texto que cambia cuando pulsas un link, por lo que la ventana se mueve.
Lo que quiero es filtrar el link que pulso y si no es ninguno de los del slide que haga la transición entre anclas.
Así que he intentado hacer algo parecido a esto. Estoy haciendo que me muestre el valor, pero no consigo sacar el id, para filtrarlo:
Código PHP:
<script type="text/javascript">
$(function(){
$('a[href*=#]').click(function() {
if (location.pathname.replace(/^//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
//añadido por mi
$del =location.pathname.replace(/^//,'')
alert($del)
if($target == "sobremi-1") {
exit;
}
if ($target == '#sobremi-2'){
exit;
}
//fin añadido
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, 2000);
return false;
}
}
});
});
</script>
Alguna idea??