2013-02-24 77 views
-1

很簡單,「.hide()」功能不起作用。我正在使用jquery-rails gem,並且在application.js中有適當的語句。jquery隱藏功能不起作用

這裏是我的代碼:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" /> 
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> 
<link rel="stylesheet" href="/resources/demos/style.css" /> 

<script> 
$(document).ready(function() { 
    $(document).ajaxSuccess(function() { 
     $("#ld").hide(); 
     //alert('Hooray!'); 
    }); 
}); 
</script> 

在佈局/ application.html.erb我

<!DOCTYPE html> 
<html> 
    <head> 
     <title><%= full_title(yield(:title)) %></title> 

     <%# two lines below allow for device-responsive formatting, see twitter-bootstrap page%> 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
     <link href="assets/css/bootstrap-responsive.css" rel="stylesheet"> 

     <%= stylesheet_link_tag "application", media: "all" %> 
     <%= javascript_include_tag "application" %> 
     <%= javascript_include_tag :highcharts %> 
     <%= csrf_meta_tags %> 
     <%= render 'layouts/shim' %> 
    </head> 

    <body> 
     <%= render 'layouts/header' %> 
     <div class="container"> 
     <%= yield %> 
     <%= render 'layouts/footer' %> 
     <%= debug(params) if Rails.env.development? %> 
     </div> 
    </body> 
</html> 

編輯:

1)如果我改改這個, hide()仍然不起作用。在瀏覽器中查看頁面源代碼時,我也清楚地看到了assets/jquery.js。

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" /> 
<script src="http://code.jquery.com/jquery-1.8.3.js"></script> 
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> 
<link rel="stylesheet" href="/resources/demos/style.css" /> 

2)在HTML我有:

<div id="#ld"> 
    <%= image_tag("ajax-loader.gif", :alt => "test image") %> 
</div> 
+0

.css()不起作用...我在哪裏可以在查看頁面源時找到這些定義? – Krishna 2013-02-24 00:04:42

+4

你可以請把包括由此產生的HTML而不是一些紅寶石模板。我無法找到你的標籤ID爲「ld」的應該是... – 2013-02-24 00:06:29

+2

你有jQuery嗎?您的HTML僅顯示jQuery UI腳本。 – 2013-02-24 00:06:40

回答

1

從您的div的ID刪除#哈希:

<div id="ld"> 

你只投入CSS和jQuery嘶嘶選擇到哈希說你正在尋找一個id,而不是一個類(.)或標籤名稱(沒有前綴)。