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 8261291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:21:24+00:00 2026-06-08T03:21:24+00:00

The class, open, gets added to the ul element, but not the dropdown#register element.

  • 0

The class, “open”, gets added to the ul element, but not the dropdown#register element.

<ul class="nav"></ul>
<script> $("#register_dropdown").addClass("open"); </script>
<script> $("ul").addClass("open"); </script>
<span class="dropdown" id="register_dropdown"></span>
  • 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-06-08T03:21:26+00:00Added an answer on June 8, 2026 at 3:21 am

    $("#register_dropdown") returns an empty jQuery object as register_dropdown is not present in the DOM when you execute that line.

    I’m not experienced with HAML, but wrapping your scripts inside the DOM ready handler is the way to go:

    %script $(function(){ $("#register_dropdown").addClass("open"); });
    

    In plain markup it should be rendered as:

    <script> $(function(){ $("#register_dropdown").addClass("open"); }); </script>
    

    You can also use the more verbose way if you prefer (same result as the one above):

    $(document).ready(function() {
        //DOM is ready, put your code here
        $("#register_dropdown").addClass("open");
    });
    

    This prevents your code from running until the DOM has fully loaded. You may as well just move that line after the element is added to the DOM, but it’s good practice to manipulate the DOM after it’s ready.

    Reference

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

Sidebar

Related Questions

Recently, I've released an open-source class - wrapper of API functions available from one
I have to open a page from class extended from javax.swing.AbstractAction class... Is that
How can I open a database connection in user class , where I can
I want to open a file from a Class in C# using a Process,
I want to open a custom dialog in onHandleIntent() method of an IntentService class,
I want to port an small open source AES encryption class to Android, and
The Desktop.getDestop().open(File) launches the associated aplication to open the file. The Desktop class is
I'm confused about this scope behavior: class Bar: def __init__(self): for fn in [open,openW,remove,mkdir,exists,isdir,listdir]:
Given a public instantiation of a class in WinForm1, I attempt to open WinForm2
I have a custom closed-hashset/open-addressing (i.e. no linked lists) class. It's very specific to

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.