Home>

I checked jQuery operation according to an introductory book, but jQuery is not working. What should I do now? (Once, gem'jquery-rails'was added (4.3.3) and the operation of javascript was confirmed.)
(Windows10 Ruby 2.4.4 Rails 5.1.6)

layouts/ajax.html.erb

<head>
    <% = csrf_meta_tags%>
    <% = stylesheet_link_tag 'ajax', 'data-turbolinks-track': 'reload'%>
    <% = javascript_include_tag 'application', 'data-turbolinks-track': 'reload'%>
  </head>

config/initializers/assets.rb (add the following two lines)

Rails.application.config.assets.precompile + =% w (ajax.css)
Rails.application.config.assets.precompile + =% w (ajax.js)

The message "jQuery is not working" is displayed below.
views/ajax/index.html.erb

<h1>Ajax # index</h1>
<p>jQuery is not working</p>
<script>
  $('# ajax'). text ('jQuery is working!')
</script>