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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:29:34+00:00 2026-06-17T20:29:34+00:00

I want to do some actions depending on a element inside a li element

  • 0

I want to do some actions depending on a element inside a li element and a submenu class in li element.
If the element has 2 classess current submenu i want to do some action when $(“.menu”).mouseenter event occurs. If the li element does not have this do something else….

    <nav id="id"> 
    <ul>
        <li><a href="index.html">index</a></li>
        <li><a href="serviceios.html" class="current submenu">Services</a></li>
        <li><a href="clients.html" >Clients</a></li>
        <li><a href="portfolio.html">Portfolio</a></li>
        <li><a href="contact.html" >Contact</a></li>
        <ul class="menu">
            <li><a href="#" class="documents" data-icon="&#xe000">1</a></li>

            <li><a href="#" class="messages" data-icon="&#xe001">2</a></li>

            <li><a href="#" class="signout" data-icon="&#xe002">3</a></li>
        </ul>
    </ul>
</nav>

I have:

$(".menu").mouseenter(
    function() {
        $(".menu").toggleClass('hover');
        $(".submenu").css("-webkit-border-radius", "8px 8px 0 0");
        $(".submenu").css("-moz-border-radius", "8px 8px 0 0");
        $(".submenu").css("border-radius", "8px 8px 0 0");
        if( $('li').hasClass('current submenu') )
            /*...*/
        else
            $(".submenu").toggleClass('current');
    }
);

what to do?

  • 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-17T20:29:36+00:00Added an answer on June 17, 2026 at 8:29 pm

    You are setting class to the a element inside the li, so a will have the class.

    Use this. This will select the a with class submenu current inside an li.

    if( $('li a.submenu').hasClass('current') ) {
        console.log("Got an li");
        /* Do stuff here */
    } else {
        $(".submenu").toggleClass('current');
    }
    

    If you are sure there is only one element with submenu class at a time, then you can also do:

    if( $('.submenu').hasClass('current') ) {
    

    Live Demo

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

Sidebar

Related Questions

I have a method that I want to take some action depending on the
I want to start several threads, retrive data from net, perform some actions with
I want my setup.py to do some custom actions besides just installing the Python
In a view, I want to consume some Json produced by an action on
Im doing some jquery stuff with toggle() , I'm doing different actions depending on
I want some examples of C preprocessor directives, such as: #define pi 3.14 #define
I want some code to be triggered every second. Usually, I'd create a Timer
I want some of the goodies in a ListView, like being able to use
I want some like this: How make it ideologically correct?
I want some static pages of application to be rendered from XML i.e. i

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.