Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6330051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:47:42+00:00 2026-05-24T17:47:42+00:00

I have a simple jquery.hide() function that is on all the divs with a

  • 0

I have a simple jquery.hide() function that is on all the divs with a class “groups”.
But for some reason it doesn’t work and I don’t know why. I’m using rails 3 and have both put the jquery in the application.js file and the actual file ‘edit’ in script tag. Both don’t work. can anyone see why?

Here’s my .html.erb file

<h1 class="head">Edit information</h1>
<%= form_for(@user) do |f| %>
  <%= render 'shared/error_messages', :object => f.object %>
  <div class="field">
    <%= f.label :username %><br />
    <%= f.text_field :username, :disabled => 'disabled' %>
  </div>
  <div class="field">
      <%= f.label :full_name %><br />
      <%= f.text_field :full_name%>
  </div>
  <div class="field">
    <%= f.label :email %><br />
    <%= f.text_field :email %>
  </div>
  <%= javascript_include_tag 'application' %>

  <div class="groups">
        <%= f.label :password %><br />
        <%= f.text_field :current_password %>

        <%= f.label :password_confirmation %><br />
        <%= f.text_field :current_password %>

        <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
        <%= f.password_field :current_password %>
  </div>

  <% if current_user.has_role? :Admin %>
  <div class="field">
  <div style="width:150px"><legend >Group</legend>
      <table border="1" width="100%">
      <tr>
            <th></th>
            <th></th>
      </tr>
      <% for role in @roles %>
      <tr>
            <td><%= role.name %></td>
            <td><%= check_box_tag "user[role_ids][]", role.id, @user.roles.include?(role) %></td>
      <tr>
      <% end %>
      </table>
      </div>
  </div>
<% else %>
<% end %>
<div class="actions">
    <%= f.submit "Update" %>
</div>
<% end %>
<%= button_to 'Back', user_path(@user) %>

and my jquery which I have used in the js file and the top of the html.erb file

function (){
    $('.groups').hide();
};

its worth noting that ive tried:

$(document).ready (function (){
    $('.groups').hide();
});

aswell.

The application.js file gets loaded in the page as does jquery.
It’s been a long day of code so I might be missing something obvious.

Update

<!DOCTYPE html>
<html>
  <head>
    <title>PadOnRails | Edit user</title>
      <meta name="csrf-param" content="authenticity_token"/>
<meta name="csrf-token" content="p64cHvc9nuBXOOHeV08Kg9FBsRxgQZlehw2xetHs57c="/>
      <!-- Stylesheets -->
<link href="/stylesheets/custom.css?1313743921" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/blueprint/screen.css?1313067331" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/blueprint/print.css?1312273016" media="print" rel="stylesheet" type="text/css" />
<link href="/stylesheets/jquery-ui.css?1313072205" media="screen" rel="stylesheet" type="text/css" />
      <script src="/javascripts/jquery-1.6.2.min.js?1312273015" type="text/javascript"></script>

<script src="/javascripts/jquery-ui-1.8.14.custom.min.js?1312273015" type="text/javascript"></script>
<script src="/javascripts/jquery_ujs.js?1312273015" type="text/javascript"></script>
<script src="/javascripts/jquery.dataTables.min.js?1312800139" type="text/javascript"></script>
<script src="/javascripts/datatable.js?1313666950" type="text/javascript"></script>
<script src="/javascripts/rails.validations.js?1312877646" type="text/javascript"></script>  
<script src="/javascripts/error_messages.js?1313056625" type="text/javascript"></script>
<script src="/javascripts/jquery.dataTables.columnFilter.js?1312807797" type="text/javascript"></script>
<script src="/javascripts/application.js?1313762558" type="text/javascript"></script>

    </head>

    <body>
        <!-- Container for all the content on the page -->
        <div class="container header">
            <header>
    <div id="top-menu">
        <div id="account">
        <ul>
        <li>Logged in as: <b>admin</b>&nbsp;&nbsp;</li>

        <li>Current IP: <b>127.0.0.1</b>&nbsp;&nbsp;</li>
        <li><a href="/users/6" class="round">My Account</a></li>
        <li><a href="/logout" class="round">Sign out</a></li>
        </ul>
        </div>
        <ul>
        <li><a href="/" class="round">Home</a></li>

        </ul>
    </div>
</header>

            <div class=" maintitle">
                <div class="lefthead">
                 <a href="/"><img alt="Matflo" src="/images/logo.png?1312273015" /></a>
                </div>
                <div class="righthead">
                PAD
                </div>

            </div>
        </div>
                  <!-- Get contents from pages -->
                <div class="container main">
                <!-- Messages Blueprint => :error [red], :success [green], :info [blue] and :notice [yellow] -->
                <h1 class="head">Edit information</h1>
<form accept-charset="UTF-8" action="/users/6" class="edit_user" id="edit_user_6" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /><input name="authenticity_token" type="hidden" value="p64cHvc9nuBXOOHeV08Kg9FBsRxgQZlehw2xetHs57c=" /></div>



  <div class="field">
    <label for="user_username">Username</label><br />

    <input disabled="disabled" id="user_username" name="user[username]" size="30" type="text" value="admin" />
  </div>
  <div class="field">
      <label for="user_full_name">Full name</label><br />
      <input id="user_full_name" name="user[full_name]" size="30" type="text" value="admin" />
  </div>
  <div class="field">
    <label for="user_email">Email</label><br />

    <input id="user_email" name="user[email]" size="30" type="text" value="admin@dai.co.uk" />
  </div>

  <div class="groups">
        <label for="user_password">Password</label><br />
        <input id="user_current_password" name="user[current_password]" size="30" type="text" />

        <label for="user_password_confirmation">Password confirmation</label><br />
        <input id="user_current_password" name="user[current_password]" size="30" type="text" />

        <label for="user_current_password">Current password</label> <i>(we need your current password to confirm your changes)</i><br />

        <input id="user_current_password" name="user[current_password]" size="30" type="password" />
  </div>

  <div class="field">
  <div style="width:150px"><legend >Group</legend>
      <table border="1" width="100%">
      <tr>
            <th></th>
            <th></th>

      </tr>
      <tr>
            <td>Developer</td>
            <td><input id="user_role_ids_" name="user[role_ids][]" type="checkbox" value="1" /></td>
      <tr>
      <tr>
            <td>Corporate</td>
            <td><input id="user_role_ids_" name="user[role_ids][]" type="checkbox" value="2" /></td>

      <tr>
      <tr>
            <td>ProjectManager</td>
            <td><input id="user_role_ids_" name="user[role_ids][]" type="checkbox" value="3" /></td>
      <tr>
      <tr>
            <td>Admin</td>
            <td><input checked="checked" id="user_role_ids_" name="user[role_ids][]" type="checkbox" value="4" /></td>

      <tr>
      <tr>
            <td>TeamLeader</td>
            <td><input id="user_role_ids_" name="user[role_ids][]" type="checkbox" value="5" /></td>
      <tr>
      <tr>
            <td>Engineer</td>
            <td><input id="user_role_ids_" name="user[role_ids][]" type="checkbox" value="6" /></td>

      <tr>
      </table>
      </div>
  </div>
<div class="actions">
    <input id="user_submit" name="commit" type="submit" value="Update" />
</div>
</form><form method="post" action="/users/6"  class="button_to"><div><input type="submit" value="Back" /><input name="authenticity_token" type="hidden" value="p64cHvc9nuBXOOHeV08Kg9FBsRxgQZlehw2xetHs57c=" /></div></form>

            </div>
        </div>

        <!-- Debug information outside page container- REMOVE WHEN FINISHED! -->
    </body>
    <div class="container">
    <div id="bottom-menu">
        <pre class='debug_dump'>--- !map:ActiveSupport::HashWithIndifferentAccess 
action: edit
id: &quot;6&quot;
controller: users
</pre>
    </div>
    </div>

</html>

Html straight out of the source as requested.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:47:42+00:00Added an answer on May 24, 2026 at 5:47 pm

    Be sure prototype is not included, the ‘$’ can be used by any library. Try this:

    jQuery(document).ready(function(){
        jQuery(".groups").hide();
    });
    

    Extra: If you writing your script out of a HTML element, the correct is use double quote notation (“”).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following simple jQuery: $('#features').hide(); $('#more').click(function(e) { e.preventDefault(); $('#more').hide(); $('#features').show(); }); This
I'm working on a table where all rows have at least one class. Some
I have a simple jQuery animation that moves a div to the right or
I have the following jquery that I wrote: $(document).ready(function(){ $('div.contentTxtBox#home').addClass('current').show(); $('a.menu').click(function() { $('div.contentTxtBox.current').hide(slide, {
I have something very simple but I can not make it work correctly in
I have a simple HTML page that contains two tabs that show/hide content in
I have a simple HTML. I am using the JQuery for AJAX purpose. Now,
I have a simple html page with a div. I am using jQuery to
I have a simple html block like: <span id=replies>8</span> Using jquery I'm trying to
Should simple JavaBeans that have only simple getters and setters be unit tested?? What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.