2017-05-11 18 views

答えて

1

そうするためのコードです:

function jqAlert(message, time) { 
      var counter = time; 
      $("#dialog").dialog({ 
       title: "Message From Web App", 
       modal: true, 
       resizable: true, 
       autoOpen: true, 
       modal: true, 
       buttons: { 
        "OK": { 
         text: "OK (" + (time/1000)+ ")" , 
         id: "btnDialogOK", 
         click: function(){ 
          $('#dialog').dialog('close'); 
         } 
        } 
       }, 
       open: function(event, ui) { 
        countdown(time); 
        $(this).html(message); 
        setTimeout(function(){ 
         $('#dialog').dialog('close');     
        }, time); 
       } 
      }); 
     } 
     function countdown(time) { 
      var timeleft = (time/1000); 
      var downloadTimer = setInterval(function(){ 
      timeleft--; 
      document.getElementById("btnDialogOK").style.padding = "7px 18px 7px 18px"; 
      document.getElementById("btnDialogOK").textContent = "OK " + "(" + timeleft + ")"; 
      if(timeleft <= 0) 
       clearInterval(downloadTimer); 
      },1000);  
     } 

onclickの内からjqAlertメソッドを呼び出すには:

jqAlert("This is an Alert", 5000); 
+0

本当に?あなたの質問は何ですか?もしあなたがすでに答えを持っているのであれば、なぜあなたは尋ねていますか? –

+0

これはチュートリアルであると思いました。 – greendave11

関連する問題