title: Rails 4 JS TypeError: $(...).previous is not a function
body: <p>i am trying to make a link called remove under a text field to destroy and hide it using java-script but it doesnt work and i am getting this error in the console <code>TypeError: $(...).previous is not a function</code></p>
  
  <p>here is the rails code in </p>
  
  <p><code>app/views/surveys/_question_fields.html.erb</code></p>
  
  <pre><code>&lt;p class="fields"&gt;
    &lt;%= f.label :content, "answer" %&gt;&lt;br /&gt;
    &lt;%= f.text_field :content %&gt;&lt;br /&gt;
    &lt;%= f.hidden_field :_destroy %&gt;
    &lt;%= link_to_function "remove", "remove_fields(this)" %&gt;
  &lt;/p&gt;  
  </code></pre>
  
  <p><code>app/assests/javascripts/application.js</code></p>
  
  <pre><code>//= require jquery
  //= require jquery_ujs
  //= require turbolinks
  //= require_tree .
  //= require cocoon
  
  function remove_fields(link) {
    $(link).previous("input[type=hidden]").value = "1";
    $(link).up(".fields").hide();
  }
  </code></pre>