Getting value with Jquery in Rails -


i have tried many things without success.

i want value introduced user (user_entry) when clicking on button (ddd).

this have:

my index.html.erb

<div >   <p class="mod1_title">intro</p>   <div class="mod1_boxed">     <strong>jahreshausverbrauch (kwh):</strong>       <%= form_tag( '/welcome/index', post: true ) %>       <%= text_field_tag "module1", nil, placeholder: "bsp. 3500", id: "user_entry" %></br>        <strong>pv-große (kwp):</strong></br>       <%= text_field_tag "module2", nil, placeholder: "bsp. 5", id: "user_entry_2" %></br>       <%= submit_tag "send", id: "ddd" %>        <%end%>   </div>   </div>   <script >  $(function(){           $("#ddd").change(function(){          var number_value =  $(this).val("#user_entry_module1");           console.log(number_value);           }); });  </script> 

any idea?

use click event on button instead of change event,

<script type="text/javascript">  $(document).ready(function(){      $("#ddd").click(function(){         var number_value =  $("#user_entry").val();         console.log(number_value);       });   });  </script> 

Comments