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

时间:2016-02-21 23:32:32

标签: jquery html css

我在主页上使用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>

<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>

1 个答案:

答案 0 :(得分:0)

首先,您需要知道文本的id / class是什么。我将使用class =&#34; text&#34;对于此示例,因为您没有为单词提供任何类/ ID。此外,单词将在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');
    });
});

文本不必是网址,只要有一个div围绕它。