[英]Deeplinking Within Flexslider (or any slider)
I want to add deeplinking into flexslider.. 我想将深层链接添加到flexslider中。
The ability to click on a specific link: 单击特定链接的能力:
<a href="#contact">whatever text..</a>
id, and it will take me to the specific slider li. id,它将带我到特定的滑块li。 Is this possible?
这可能吗? eg
例如
<ul>
<li id="title">...</li>
<li id="title2">...</li>
<li id="title3">...</li>
<li id="contact">...</li>
</ul>
-Neil -Neil
Use the JavaScript's window.location.hash
. 使用JavaScript的
window.location.hash
。 Use any of these: 使用以下任何一种:
var hash = $(this).attr('href').split('#')[1];
var hash = $(this).attr('href').replace(/^.*?#/,'');
var hash = $(this).attr('href').substr(test.indexOf('#')+1);
var hash = $(this).attr('href').match(/#(.*$)/)[1];
Use this code then: 然后使用此代码:
var hash = window.location.hash;
$("#" + hash).show();
This will show the particular div
from the given URL. 这将显示给定URL中的特定
div
。 You can take this code as a reference: 您可以将此代码作为参考:
JavaScript JavaScript的
$(document).ready(function(){
var hash = window.location.hash;
$("#hash").html(hash);
$("div").removeClass("selected");
$(hash).addClass("selected");
});
HTML 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 CSS
.selected {background: #ff0;}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.