2013-07-25 67 views
1

我想讓這個javascript工作,我想顯示隱藏(顯示:無)div當用戶點擊按鈕。誰能告訴我我要去哪裏?。顯示jquery功能 - 不顯示div

http://jsfiddle.net/tz52u/

實施例是上述的網站上。我使用

代碼:

 $(document).ready(function() { 
    $("#show").click(function() { 
    $(".no-show").show(); 
    }); 
    }); 

感謝您的幫助。

真的很感激!

+0

你有HTML'

1

您在JavaScript領域,這已經是裹着的jsfiddle對負載運行使用html標籤<script>

您沒有通過將它選擇到左側來引用jQuery,因此$未定義。

此外,您不再需要$(document).ready() - jQuery現在提供$(function(){ console.log("Document is ready"); });這是在頁面準備就緒時執行代碼的更便捷方式。

這裏有一個固定的版本:http://jsfiddle.net/tz52u/9/

$("#show").click(function(){ 
     console.log("Button clicked!"); 
    $(".no-show").show(); 
    }); 
1

防止單擊處理程序無法正常表現:

$(document).ready(function() { 
    $("#show").click(function (e) { 
    e.preventDefault(); 
    $(".no-show").show(); 
    }); 
});