【问题标题】:Fire the plugin swipebox on load with links that include hash tag加载包含哈希标签的链接时触发插件滑动框
【发布时间】:2017-02-03 05:23:25
【问题描述】:

html代码:

<a id="image1" href="images/1.jpg" class="swipebox" title="My Caption">
    <img src="images/1mini.jpg" alt="image" />
</a>

当用户使用以 '#1' 结尾的链接进入时触发 pugin 的 Js 代码

<script type="text/javascript">
    $(document).ready(function(){
        if(window.location.hash == "#1") {
            $( '#image1' ).swipebox();
        }
    });
</script>

我发现是js代码

$( '#image1' ).swipebox();

仅当我单击图像时才有效。但我需要在页面加载期间它已经弹出。

【问题讨论】:

标签: javascript jquery html jquery-plugins popup


【解决方案1】:

在页面加载时打开swipebox;你能试试下面的代码吗:

<script type="text/javascript">
    $(document).ready(function(){
        if(window.location.hash == "#1") {
            $( '#image1' ).swipebox();
            $( '#image1' ).click();//click the image programmatically
        }
    });
</script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-23
    • 1970-01-01
    • 2018-11-26
    • 1970-01-01
    • 1970-01-01
    • 2011-06-14
    相关资源
    最近更新 更多