Flexslider(或任何滑块)内的深层链接 [英] Deeplinking Within Flexslider (or any slider)

查看:129
本文介绍了Flexslider(或任何滑块)内的深层链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在flexslider中添加深层链接.

I want to add deeplinking into flexslider..

点击特定链接的能力:

<a href="#contact">whatever text..</a>

id,它将带我到特定的滑块li.这可能吗?例如

id, and it will take me to the specific slider li. Is this possible? e.g.

<ul>
    <li id="title">...</li>
    <li id="title2">...</li>
    <li id="title3">...</li>
    <li id="contact">...</li>
</ul>

-Neil

推荐答案

使用JavaScript的window.location.hash.使用以下任何一种方法:

Use the JavaScript's window.location.hash. Use any of these:

  1. var hash = $(this).attr('href').split('#')[1];
  2. var hash = $(this).attr('href').replace(/^.*?#/,'');
  3. var hash = $(this).attr('href').substr(test.indexOf('#')+1);
  4. var hash = $(this).attr('href').match(/#(.*$)/)[1];
  1. var hash = $(this).attr('href').split('#')[1];
  2. var hash = $(this).attr('href').replace(/^.*?#/,'');
  3. var hash = $(this).attr('href').substr(test.indexOf('#')+1);
  4. var hash = $(this).attr('href').match(/#(.*$)/)[1];

然后使用此代码:

var hash = window.location.hash;
$("#" + hash).show();

这将显示给定URL中的特定div.您可以将此代码作为参考:

This will show the particular div from the given URL. You can take this code as a reference:

JavaScript

$(document).ready(function(){
    var hash = window.location.hash;
    $("#hash").html(hash);
    $("div").removeClass("selected");
    $(hash).addClass("selected");
});

HTML

<a href="#one">One</a>
<a href="#two">Two</a>

<div id="one">One</div>
<div id="two">Two</div>
<div id="hash"></div>

CSS

.selected {background: #ff0;}

这篇关于Flexslider(或任何滑块)内的深层链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆