jQuery not working on Rails 3.2.8

后端 未结 4 1695
一向
一向 2021-01-19 22:07

I\'m having an issue with jQuery on Rails 3.2.8. I\'ve installed the jquery-rails gem and my application.js has the following:

//= require jquery
//= require         


        
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-19 22:16

    You probably want to check the console in the browser you are testing.

    In jQuery's case, $ is just an alias for jQuery, does the following work

    jQuery(document).ready(function(){
       jQuery("a").click(function(event){
         alert("Thanks for visiting!");
       });
    });
    

    Perhaps you have called jQuery.noConflict() somewhere, removing the alias?

    http://api.jquery.com/jQuery.noConflict/

提交回复
热议问题