2014-10-01 156 views
2

此代码工作打开vanillabox图像点击,但我需要实现按钮点击此代码..我曾尝试与点击()方法,但它亘古不变的工作..按钮/图像打开弹出点击

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

上面的代码测试定义为按钮id..please检查下面

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

回答

2

HTML尝试下面

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

确保您已添加css & js香草盒。