2016-08-05 4 views

答えて

0

あなたが機能に名前を付けたり、変数に代入する必要があります。

var run_databases = function() { 
 
    alert('welcome'); 
 
}; 
 

 
// You need to name this function 
 
function setTimeOutFoo() { 
 

 
    window.setTimeout(run_databases, 1000); 
 

 
}; 
 

 
// Or assign the unnamed function to a variable 
 
var setTimeOutVar = function() { 
 

 
    window.setTimeout(run_databases, 1000); 
 

 
}; 
 

 
setTimeOutFoo(); // Calling the function 
 
setTimeOutVar();

あなたはこのような何かを試すことができます。

window.onload = function() { 
 
    console.log('Page has finished loading'); 
 
    
 
    //I am adding a time out so you can see the loading 
 
    // You can remove the "setTimeout(function() {" 
 
    // And you can also remove the "}, 2000);" 
 
    
 
    setTimeout(function() { // Remove this line 
 
    
 
    document.getElementById('loading').innerHTML = "Page Loaded"; 
 
    
 
    }, 2000); // Remove this line 
 
    
 
};
<p id="loading">Page Loading...</p>

最も簡単な方法は、ボタンにツールチップを追加するには、次のとおりです。

var btn = document.getElementById("btn"); 
 

 
btn.setAttribute('title', 'This is the tool tip set in JavaScript');
<!-- Done with JavaScript --> 
 
<button id="btn">Hover here!</button> 
 

 
<!-- Done in the HTML --> 
 
<button id="btn" title="This is tool tip set in HTML">No! Hover here :)</button>

+0

同様のコーディング方法を使用して読み込みウィンドウを表示できますか? – Shas

+0

@ user6681863編集を参照 –

+0

javascriptの更新ボタンのツールチップを割り当てる方法??? – Shas

1

他の機能のラッピング(閉鎖)は必要ありません:

var run_databases = function() { 
 
    alert('welcome'); 
 
}; 
 

 
window.setTimeout(run_databases, 1000);

+0

同様のコーディング方法を使用して読み込みウィンドウを表示できますか? – Shas

0

ます自己のinvを使用しています匿名関数をokingが、あなたの構文が間違っている:あなたはちょうどしようといけない理由

var run_databases = function() { 
    alert('welcome'); 
}; 

(function(){ 
    window.setTimeout(run_databases, 1000); 
})(); 

Working example

+0

javascriptの更新ボタンにツールチップを割り当てる方法??? – Shas

+0

新しい質問を投稿、人々はあなたのためにコードするためにここにいません。この最初の記事を読むhttp://stackoverflow.com/help/how-to-ask –

関連する問題