简体   繁体   English

如何在显示模态后调用函数

[英]how to call a function after reveal-modal appears

I am working in a foundation frame work for responsive. 我正在一个基础框架工作,以响应。 on click of a link say 点击链接说

<a href="#" class="button" data-reveal-id="myModal">Click Me For A Modal</a>

<div id="myModal" class="reveal-modal" data-reveal>
  <h2 id="modalTitle">Awesome. I have it.</h2>
  <p class="lead">Your couch.  It is mine.</p>
  <p>I'm a cool paragraph that lives inside of an even cooler modal. Wins!  </p>
  <a class="close-reveal-modal" aria-label="Close">&#215;</a>
</div>

I want as the window opens the focus is given to the myModal. 我希望随着窗口的打开,重点放在myModal上。

i am trying 我在尝试

$('a.button').on('click', function() {
    $("#myModal").attr("tabindex","0").focus();
 });

but it not working. 但它不起作用。

My script is running before the modal window opens and thus there is no such element available to receive focus. 我的脚本在模态窗口打开之前运行,因此没有可用于获得焦点的元素。

You can set the focus on the whole modal. 您可以将焦点设置在整个模态上。

$('a.button').on('click', function() {
   $("#myModal").focus();
});

Is this what you where looking for? 这是你在哪里寻找的?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM