2014-10-01 191 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香草盒。