Jquery — Countdown, bind,unbind,

blossom0417
1 min readJun 21, 2019

--

Today’s work

  1. condition
  • Count down from 5 to 0 when the modal popup show then disappear!
  • but if a user click anywhere outside of modal popup while countdown. this modal popup should not disappear.
  • countdown function fire once as user click while countdown
  • there are two modal which is a count down modal popup and confirm popup

https://codepen.io/kes3583/pen/ZdebWj?editors=0010

  1. jquery — bind , unbind event — The unbind() method was deprecated in version 3.0. Use the off() method instead.
  2. deprecated — 중요도가 떨어져 사용하지 않는
$(document).ready(function(){
$("p").click(function(){
$(this).slideToggle();
});
$("button").click(function(){
$("p").unbind();
});
});
///Unbind a specific function
function alertMe() {
alert("Hello World!");
}
$(document).ready(function(){
$("p").click(alertMe);
$("button").click(function(){
$("p").unbind("click", alertMe);
});
});
//mycode
if (countdown > 0) {
modalToggle.unbind("click", showMConfirmModal);
} else {
modalToggle.bind("click", showMConfirmModal);
clearInterval(downloadTimer);
modal.removeClass("is-visible");
}

2. javascript — Print textContent

get a element text
var x = document.getElementById("myList").textContent;
set/change the textual content of a elementdocument.getElementById("demo").textContent = "Paragraph changed!";

3. countdown Javascript

var timeleft = 10;
var downloadTimer = setInterval(function(){
timeleft--;
document.getElementById("countdowntimer").textContent = timeleft;
if(timeleft <= 0)
clearInterval(downloadTimer);
},1000);

--

--

No responses yet