簡體   English   中英

如何在顯示模態后調用函數

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

我正在一個基礎框架工作,以響應。 點擊鏈接說

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

我希望隨着窗口的打開,重點放在myModal上。

我在嘗試

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

但它不起作用。

我的腳本在模態窗口打開之前運行,因此沒有可用於獲得焦點的元素。

您可以將焦點設置在整個模態上。

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

這是你在哪里尋找的?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM