简体   繁体   English

jQuery外部链接的问题

[英]issue with jquery external linking

I am working on jquery. 我正在开发jquery。 I have 4 tabs within the <li> tags. 我在<li>标记内有4个标签。 I have used jquery 1.9.1.js for my project. 我已经为我的项目使用了jquery1.9.1.js。 my <li> looks like the one below. 我的<li>看起来像下面的那个。 I got a solution to use http://www.asual.com/jquery/address/docs/#api-reference . 我有一个使用http://www.asual.com/jquery/address/docs/#api-reference的解决方案。 But the fact is that I have used and imported this external lib but it doesn't seem to work. 但是事实是我已经使用并导入了这个外部库,但是它似乎不起作用。 The thing which i am trying to attain is when ever I select the specific <li> item and press f5 the page by default loads the first <li> item. 我要达到的目的是,当我选择特定的<li>项目并按f5键时,默认情况下该页面将加载第一个<li>项目。 But the thing which I am looking for is , it has to load the same selected <li> item and its contents when refreshed. 但是我要寻找的是,刷新时必须加载相同的选定<li>项目及其内容。 any help would be appreciated. 任何帮助,将不胜感激。

Here is my HTML code: 这是我的HTML代码:

<div class="container">
    <div class="coolbar">
        <div class="cool-inner">
            <ul id="mybar" class="nav cool-tabs">
                <li class="Coke">
                    <a href="#" data-toggle="tab">Coke </a><span class="dashboard-bottom"></span>
                </li>
                <li class="Fanta">
                    <a href="#" data-toggle="tab">Fanta</a><span class="Pricing-bottom"></span>
                </li>
                <li class="Pepsi">
                    <a href="#" data-toggle="tab">Pepsi</a><span class="Promotion-bottom"></span>
                </li>
                <li class="Limca">
                    <a href="#" data-toggle="tab">Limca</a><span class="Product-bottom"></span>
                </li>
            </ul>
        </div>
    </div>
</div>.
<div id="login"> 
    <button type="button" id="submit" value="Login" class="btn">Click me for cool drinks</button>
</div>

And my jquery code for page refresh: 和我的页面刷新的jQuery代码:

$(function() {
    $('#submit').click(function() { 
        $('.container').show();
        $('#login').hide();
        $.cookie('shown', true);
    });
    if ($.cookie('shown')) {
        $('#submit').click()
    }
});

Thanks in advance. 提前致谢。

when activating the tab you may want to set the tabs position/value in the cookie and when the page loads, check if tabs position/value exist in the cookie, then accordingly activate that tab or trigger click event on that tab. 激活选项卡时,您可能需要设置cookie在cookie中的位置/值,并且在页面加载时,检查cookie中是否存在选项卡位置/值,然后相应地激活该选项卡或触发该选项卡上的click事件。

may this help 可以帮忙吗

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

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