繁体   English   中英

如何在层滑块中使横幅的一部分可单击

[英]How to make part of a banner clickable in layer slider

我正在主页上使用layerslider来显示几个横幅,并且我希望用户单击每个横幅上的文本以将它们重定向到另一个页面,因此我需要将该文本指定为链接并保持设计响应。 我怎样才能做到这一点?

这是滑块演示页面:

http://kreaturamedia.com/layerslider-responsive-jquery-slider-plugin/

我的

 <div id="layerslider" style="width: 100%; height: 396px; visibility: visible;" class="ls-container ls-v5"> <!-- slide one start --> <div class="ls-inner" style="width: 1903px; height: 396px; background-color: transparent;"><div class="ls-lt-container ls-overflow-hidden" style="width: 1903px; height: 396px; display: block;"></div><div class="ls-slide" data-ls="slidedelay: 8000;transition2d:5;timeshift:-1000;" style="width: 0px; height: 396px; visibility: visible; display: none; left: 0px; right: auto; top: 0px; bottom: auto;"> <!-- slide background image --> <img src="./Home2_files/slide1.jpg" class="ls-bg ls-preloaded" alt="Slide background" style="z-index:0; padding: 0px; border-width: 0px; width: 1903px; height: 470.993px; margin-left: 0px; margin-top: -37.4963px; visibility: hidden;"><div class="ls-gpuhack" style="width: auto; height: auto; padding: 0px; border-width: 0px; left: 301.5px; top: 0px;"> <a href="MY_URL_link" class="link"></a> </div> 

首先,您需要知道文本的ID /类。 在本示例中,我将使用class =“ text”,因为您没有为单词提供任何类/标识。 另外,这些单词将在div内,因此将是<div class="text">Text goes here</div>

使用jQuery,您可以执行以下操作:

$("document").ready(function{
    $(".text").click({
        $(location).attr('href', 'your url here');
    });
});

然后,您可以根据需要多次使用此代码,如下所示:

$("document").ready(function{
    $(".text").click({
        $(location).attr('href', 'your url here');
    });
    $(".text2").click({
        $(location).attr('href', 'your url here');
    });
});

文本不必是url,只要周围有div。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM