include jquery in rails 3
In my rails application I am trying to include jquery focus effect for a
search button. When the mouse is over that button it should change the
color. But the jquery code is not working ,although I tried using
search.js,search.js.erb.In the gems file I have also included jquery rails
in Gem file and also tried bundle install.
<!DOCTYPE html>
<html>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("text_field_tag").focus(function(){
$(this).css("background-color","#cccccc");
});
$("text_field_tag").blur(function(){
$(this).css("background-color", "#ffffff");
});
});
</script>
<body>
<%=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" ) %>
<% end %>
</body>
</html>
I also tried by removing the "script src" tag even then its not
working.Anybody please help..
No comments:
Post a Comment