簡體   English   中英

單擊添加類然后刪除的jQuery Modal

[英]Jquery Modal on click add class then remove

這段代碼應該添加一個類,然后延遲刪除整個div。 它只是跳轉到刪除div。 有什么想法嗎?

HTML

 <!-- modal conent-->
    <div class="modal" id="modal">
     <div class="modal-content ">
      <h1>Tricks Are 4 Kids</h1>
     <p>Ok so my modal doesn't look like this one, but this is it boiled down. Can I write the JS better??? ....</p>
       <button href="#" class="close" id="close" >X</button>
      </div>
    </div>
    </div>
 <!-- page conent-->
    <div id="page-content-wrapper" >I am a div with all the page conent. lalalalala</div>

CSS

.red {background:red;}

jQuery的

$(document).ready( function() {
    $( "#close" ).click(function() {
        $("#modal").addClass("red").delay(800).queue
        $("#modal").remove();
    });

Codepen https://codepen.io/Ella33/pen/GjQZRP

$(document).ready( function() {
  $( "#close" ).click(function() {
    $("#modal").addClass("red");
    setTimeout(function() {
        $("#modal").remove();
    }, 800); 
});

暫無
暫無

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

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