javascript - 通过 Javascript 打开和关闭 Reveal 模式

标签 javascript zurb-foundation

我正在尝试通过 Javascript 打开和关闭 Reveal 模式...

我有这个 HTML

<div class='reveal-modal' id='first-modal' data-reveal>
   I'm the firstborn!
   <a class='open-second'>Click me!</a>
</div>
<div class='reveal-modal' id='second-modal' data-reveal>
   I'm the secondborn!
   <a class='close'>Close modal</a>
</div>
<a class='open-first'>Click me!</a>

以及以下 Javascript...

// There's no need to close a previous modal before you
// open another one.
$('a.open-first').on('click', function() {
  $('#first-modal').foundation('reveal','open');
});
$('a.open-second').on('click', function() {
  $('#second-modal').foundation('reveal', 'open');
});
$('a.close').on('click', function() {
  $('#second-modal').foundation('reveal', 'close');
});

但是,我看到以下错误...

app.js:16078 Uncaught ReferenceError: We're sorry, 'reveal' is not an available method for Reveal.
    at jQuery.fn.init.foundation (app.js:16078)
    at HTMLAnchorElement.<anonymous> (app.js:14672)
    at HTMLAnchorElement.dispatch (app.js:5026)
    at HTMLAnchorElement.elemData.handle (app.js:4831)

谁能告诉我为什么这不起作用?

谢谢!

最佳答案

我设法找到了答案......

这只是删除“reveal”的问题,因此......

$('a.open-first').on('click', function() {
  $('#first-modal').foundation('open');
});
$('a.open-second').on('click', function() {
  $('#second-modal').foundation('open');
});
$('a.close').on('click', function() {
  $('#second-modal').foundation('close');
});

关于javascript - 通过 Javascript 打开和关闭 Reveal 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51589197/

相关文章:

javascript - Zurb Foundation 4 显示模态 : Won't close

dart - AngularDart 和 Zurb 基金会可以合作吗?

css - Foundation Block Grid 和 nth-child 选择器

javascript - 设置 react 谷歌地图时遇到问题

javascript - SVG getIntersectionList 返回 null

javascript - setTimeout 在控制台上的随机行为。如何按顺序获取计数以及此行为的原因?

javascript - 如何防止在数组中打印当前值(除了其他值)

javascript - EmberJS jQuery 弃用和基础

html - 如何维护符合Zurb Foundation 3框架的div

javascript - 每次点击时更改 Div 类