javascript - 我如何从多个链接调用相同的 fancybox javascript?

标签 javascript html fancybox

fancybox 模态弹出窗口使用了一点 javascript:

$("#PeoplePopup").fancybox({
'autoScale'         : false,
'padding'           : 0,
'width'             : 800,
'height'            : 600,
'transitionIn'      : 'elastic',
'transitionOut'     : 'elastic',
'type'              : 'iframe',
'overlayColor'      : '#000',
'overlayOpacity'    : 0.5
});

点击链接时触发:

<a href = "peoplesearch.aspx"  class="SmallWhite" 
      id="PeoplePopup">Search for Internal Contact details &gt; </a>

如何从多个链接调用相同的弹出代码?

最佳答案

用户 class 而不是 id,所以你可以多次调用 popupcode。

//html
<a href = "peoplesearch.aspx"  class="SmallWhite PeoplePopup">
         Search for Internal Contact details </a>

//other links
<a href = "peoplesearch2.aspx"  class="PeoplePopup">...</a>
<a href = "peoplesearch3.aspx"  class="PeoplePopup">...</a>

//this jquery code will apply to the three links above
$(".PeoplePopup").fancybox({
    //the same code here 
})

关于javascript - 我如何从多个链接调用相同的 fancybox javascript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11735449/

相关文章:

javascript - 当我不期望时变得不确定

php - 错误异常 : Array to string conversion in PHP

jquery - YouTube onPlayerStateChange无法触发

javascript - select2 - 如何允许空值

javascript - dojo dgrid 自定义渲染单元格内容

html - 如何仅使用 css 在 iphone 经典风格中设置聊天气泡的样式

javascript - Fancybox自定义指定拇指

jquery fancybox 媒体助手

javascript - Web/桌面通知 API - 刷新页面时强制关闭所有通知

java - jmesa 将 html 呈现为文本