jquery - 单击按钮/图像打开弹出窗口

标签 jquery html

此代码可以在图像点击时打开 vanillabox,但我需要为按钮点击实现此代码。我尝试过使用 click() 方法,但它不起作用。

$(document).ready(function() {
    $('#test').click(function(){
        $('#grouped-image-list a').vanillabox();
    });
});

上面的代码将 test 定义为按钮 id..请检查下面的 html

<button id="test" name="test" value="Click1">click1</button>
<div class="double-column">
    <div class="column1">
        <ul id="grouped-image-list" class="link-list">
            <li><a href="HD_Wallpaper/App-screen-1.png" title="Main Screen"><img src="HD_Wallpaper/App-screen-1.png" border="0" width="300" height="300"/></a></li>
            <li><a href="HD_Wallpaper/App-screen-2.png" title="Screen2"><img src="HD_Wallpaper/App-screen-2.png" border="0" width="300" height="300"/></a></li>
            <li><a href="HD_Wallpaper/App-screen-3.png" title="Screen3"><img src="HD_Wallpaper/App-screen-3.png" border="0" width="300" height="300"/></a></li>

        </ul>
    </div>

最佳答案

尝试下面

  $(document).ready(function() {
      $('#grouped-image-list a').vanillabox();
      $('#test').click(function(){
             $('#grouped-image-list').find('a:first').trigger('click');
      });
  });

确保您已添加 vanillabox 的 css 和 js。

关于jquery - 单击按钮/图像打开弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26135585/

相关文章:

javascript - Ajax 调用总是返回错误 500 客户端

javascript - 为什么 UTF-8 字符在 jquery textcomplete 中不起作用?

jquery - 如何在网站内容后面创建居中的图像幻灯片

php - 有没有办法在 gmail/wave/gdocs 中粘贴代码片段/ block ?

html - CSS : increase background div height as per the content

javascript - 提交ajax后清除表单值

jquery - 页面加载后第一次快速淡入

javascript - 如何在邮件签名中使用位智导航链接

javascript - 为什么 Google ReCaptcha v2 复选框会在移动设备上超过 5 分钟的空闲时间后中断?

javascript - Ng-Class 导致页面首次加载时两个类处于事件状态