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 ; } |