2013-03-24 85 views
0

請幫助這個div警告框......這不關上點擊事件警告框不關閉

<script type="text/javascript"> 
    $(document).ready(function(){ 
    $('.nof-close').click(function(){ 
      $('.afp-p-now').fadeOut(); 
      $('.afp-p-now').css('display','none'); 

     }); 

    }); 
    </script> 

<div class="flash-messages container afp-p-now"> 
     <div class="flash flash-notice">Welcome to website...You are currently viewing me 
     <span class="mini-icon mini-icon-remove-close nof-close close"></span> 
     </div> 
     </div> 

任何想法將大大appreciated.Thanks。

+5

我沒有看到該代碼中的警告框。 – Rob 2013-03-24 15:51:36

+0

@Rob我認爲OP正在呼叫他的'div'一個警告框... – ShuklaSannidhya 2013-03-24 15:52:48

+0

你有什麼錯誤嗎?甚至是否已將jQuery腳本添加到您的網頁?有點[小提琴](http://jsfiddle.net)可能是一個不錯的選擇。你的代碼看起來很好。 – ShuklaSannidhya 2013-03-24 15:53:25

回答

0

這是因爲沒有什麼可點擊的,跨度沒有內容。 試試這個:

<script type="text/javascript"> 
$(document).ready(function(){ 
    $('.nof-close').click(function(){ 
     $('.afp-p-now').fadeOut();   
    });  
}); 
</script> 
<div class="flash-messages container afp-p-now"> 
    <div class="flash flash-notice">Welcome to website...You are currently viewing me 
     <span class="mini-icon mini-icon-remove-close nof-close close">[Click here to close]</span> 
    </div> 
</div> 

你也可以改變跨度爲一個按鈕(<button class="mini-icon mini-icon-remove-close nof-close close">Close</button>)。