0
在我的rails應用程序中,我需要添加一個jQuery效果。點擊按鈕時應該使段落標記中的內容隱藏的按鈕。我嘗試了所有可能的方法,但它不工作 的觀點包括軌道3中的jquery 3
<p id = "para1">
<% javascript_include_tag "tweets" %>
<%=form_tag({controller: 'tweets', action:'index'}, method: "get") do %>
<%=label_tag(:search, "Search for:") %>
<%=text_field_tag(:text)%>
<%=label_tag(:show, "Show for:") %>
<%=text_field_tag(:show) %>
<%= submit_tag("GO") %>
</p>
<button type = "button" onclick= "myfunction()">Try it</button>
<%end %>
我的代碼已經包含在裏面的應用程序/資產/ JavaScript的文件夾
<script>
$(document).ready(function(){
$("button").click(function(){
$(#para1).hide();
});
});
</script>
但在我的最後tweets.js我的jQuery代碼我幫助我
你應該使用像firebug這樣的工具來檢查jQuery是否正確加載,並且沒有javascript錯誤;在'
'部分'javascript_include_tag'也會更好。 – Baldrick