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

  • Home
  • SEARCH
  • 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 3243284
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:24:52+00:00 2026-05-17T18:24:52+00:00

what is the best way to optimize the following snippets that uses delegate()? jQuery(‘.menu’).delegate(‘li.gallery’,

  • 0

what is the best way to optimize the following snippets that uses delegate()?

jQuery('.menu').delegate('li.gallery', 'hover', function () { jQuery(this).children('.submenu').toggleClass('hide show'); });
jQuery('.menu').delegate('li.interior', 'hover', function () { jQuery(this).children('.submenu').toggleClass('hide show'); });
jQuery('.menu').delegate('li.exterior', 'hover', function () { jQuery(this).children('.submenu').toggleClass('hide show'); });


<li class="gallery"> 
                    <span>gallery</span> 
                    <ul class="submenu hide"> 
                        <li class="interior"> 
                            <a href="/gallery/interior">Interior</a> 
                            <ul class="submenu hide"> 
                                <li><a href="/gallery/interior?gallery=master-bedroom">Master Bedroom</a></li> 
                                <li><a href="/gallery/interior?gallery=living-room">Living Room</a></li> 
                                <li><a href="/gallery/interior?gallery=dining-room">Dining Room</a></li> 
                                <li><a href="/gallery/interior?gallery=kitchen">Kitchen</a></li> 
                                <li><a href="/gallery/interior?gallery=bathroom">Bathroom</a></li> 
                                <li><a href="/gallery/interior?gallery=foyer">Foyer</a></li> 
                                <li><a href="/gallery/interior?gallery=study">Study</a></li> 
                                <li><a href="/gallery/interior?gallery=sunroom">Sunroom</a></li>                                
                                <li><a href="/gallery/interior?gallery=guest-room">Guest Room</a></li>                                                              
                            </ul> 
                        </li> 
                        <li class="exterior"> 
                            <a href="/gallery/exterior">Exterior</a> 
                            <ul class="submenu hide"> 
                                <li><a href="/gallery/exterior?gallery=landscapes">Landscape</a></li> 
                                <li><a href="/gallery/exterior?gallery=gardens">Gardens</a></li> 
                                <li><a href="/gallery/exterior?gallery=cottages">Cottages</a></li> 
                                <li><a href="/gallery/exterior?gallery=entry-driveway">Entry/Driveway</a></li>                                                                                              
                            </ul> 
                        </li>                       
                    </ul> 
                </li>
  • 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-17T18:24:53+00:00Added an answer on May 17, 2026 at 6:24 pm

    You can use a multiple selector (,) in the .delegate() selector parameter.

    However, due to what I would consider a bug in how .delegate() works (off mouseover/mouseout, which fires when entering a child) I’d steer clear it it for now and bind directly, like this:

    jQuery('.menu').find('li.gallery, li.interior, li.exterior').hover(function () {
      jQuery(this).children('.submenu').toggleClass('hide show'); 
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best way to optimize the following so i have a shorter
What is the best way to optimize a MYSQL server that has 400-1000 queries
What would be the best way to optimize this code below to make it
I am just wondering what the best way to optimize PHP code is. Is
I'd like to hear some thoughts on the best way to optimize our schema
What is the best optimized way to convert table base design to table less
I'm curious about what be the best way to model this for optimized performance...
Best way to match 2 pages for Google analytics. Pages to Query: 1.) this_google.html
The best way I think to explain this is to tell you what my
The best way to explain my problem is by a example. I have a

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.