2016-08-14 117 views
0

我試圖添加淡入/淡出效果到使用jquery創建的div,但我似乎無法弄清楚。有任何想法嗎 ?如何將淡入淡出效果添加到jquery append

繼承人我當前的代碼:

if (sessionStorage.getItem('hintOnce') !== 'true') { 
     $('body').append('<div class="control-hint"><p> Use the controls to improve your browsing experience. </p><div class="close">X</div></div>') 
     sessionStorage.setItem('hintOnce','true'); 
     } 

     $('.control-hint').on('click',function(){ 
     $('.control-hint').hide(); 
     }); 

由於提前,

斯科特。

回答

1

敷在JQ對象,然後在衰退之前隱藏:

$('body').append($('<div class="control-hint"><p> Use the controls to improve your browsing experience. </p><div class="close">X</div></div>').hide().fadeIn()); 
+0

感謝。很棒。 –

0

廣告內嵌樣式display: none您股利。然後只需選擇它並致電fadeOut就可以了。

$('body').append('<div class="control-hint" style="display: none"><p> Use the controls to improve your browsing experience. </p><div class="close">X</div></div>'); 
$('.control-hint').fadeOut(); 
0

試試這個代碼:

$('<div class="control-hint"><p> Use the controls to improve your browsing experience. </p><div class="close">X</div></div>').appendTo("body").hide().fadeIn(300);