アクセスした際に任意のメッセージを少しの間、表示する

Ads

Result


よく見かけるやつです。

jQuery

function foo (bar) {
//メッセージを表示する要素を探す
    if (jQuery("body").find("#infoBox").length == 0) {
//メッセージを表示する要素
		jQuery("body").prepend("<div id=\"infoBox\"></div>");
	} 
	//指定したテキストを要素に挿入、スライドダウンし、一定の時間たったらスライドアップ
	jQuery("body").find("#infoBox").text(bar).slideDown().delay(3000).slideUp();
}
//表示させるテキスト
foo('こんにちは!こんにちは!');

css

#infoBox{
  height: 20px;
  background-color:#ffffff;
  width:100%;
  display:none;/*非表示にしておく*/
  text-align:center;
  border-bottom:#2BBAE4 1px solid;
}

via

Put a message in top of the page with jQuery

タイトルとURLをコピーしました