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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:12:07+00:00 2026-05-28T11:12:07+00:00

How do I select a list item that has a CSS hover pseudo-class using

  • 0

How do I select a list item that has a CSS hover pseudo-class using jquery?

for example,

        <ul>
            <li>test 1</li>
            <li>test 2</li>
            <li>test 3</li>
            <li>test 4</li>
       </ul>

       <style>
               ul li:hover
               {
                  background-color: black;
               }
       </style>

jquery code does not work, alert message is not displayed

       $("ul li:hover").click(function()
       {
              alert("test");                   
       });

Question:

Am I selecting the active hover state correctly in the jquery code above? And if not, what is the correct way to select it?

  • 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-28T11:12:08+00:00Added an answer on May 28, 2026 at 11:12 am

    The way you try it cannot work, as the Event-handler will only be bound to items that are hovered in exact the milliseconds the code is executed.

    You will need something like this:

    $("ul li").click(function() {
        if ($(this).is(':hover')) alert('test');
    });
    

    Demo: http://jsfiddle.net/TimWolla/3mdpG/

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

Sidebar

Related Questions

Using jQuery, what is the easiest way to select an item in a drop
I've a class that has a list of IDs with a function for adding
I'm working with an unordered list of links that has two levels: <ul class=level-1>
I have a select list which is being populated using the values from a
I have a page that has multiple select lists and when ever one of
I'm working on an table drill-down style iPhone app that has prepopulated data. I
There is a table alt text that uses CSS (by using inherit in CSS)
I'm working with a winForms app that has a listView. That listView has multi-select
I have this SearchMenuActivity that has a bunch of options the user can select.
I have a sharepoint list that has a number column call xyz i am

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.