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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:12:32+00:00 2026-06-01T15:12:32+00:00

How can I trigger the distant element which associates with the current button? For

  • 0

How can I trigger the distant element which associates with the current button?

For instance,

HTML

<ul class="menu-1">
    <li><a href="#">button 1</a></li>
    <li><a href="#">button 2</a></li>
    <li><a href="#">button 2</a></li>
</ul>

<ul class="menu-2">
    <li><a href="#">button 1</a></li>
    <li><a href="#">button 2</a></li>
    <li><a href="#">button 2</a></li>
</ul>

So when I hover the button 1 in menu-1, the button 1 in menu-2 should be hovered too.

And so when I hover the button 1 in menu-2, the button 1 in menu-1 should be hovered too.

my working jquery,

$(".menu-1 li").hover(function () {

        var text = $(this).text();

        if ($('.menu-2 li a:contains("'+text+'")').length > 0) {
            $('.menu-2 li a:contains("'+text+'")').trigger("mouseenter");
        }
    });

jsfiddle,

http://jsfiddle.net/JDG7U/

  • 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-01T15:12:33+00:00Added an answer on June 1, 2026 at 3:12 pm

    The approach I used is to replace your :hover with a .hover class and assign the CSS changes to that class. Then I added a data- attribute to each li and filtered on that. (Using a class caused problems, because I couldn’t read an arbitrary class attribute without picking up the hover class as well.)

    A bit complicated, but it left some pretty short and simple code, and it permits reordering of the elements if you need that.

    HTML:

    <ul class="menu-1">
        <li data-num="1"><a href="#">button 1</a></li>
        <li data-num="2"><a href="#">button 2</a></li>
        <li data-num="3"><a href="#">button 3</a></li>
    </ul>
    
    <ul class="menu-2">
        <li data-num="2"><a href="#">button 2</a></li>
        <li data-num="3"><a href="#">button 3</a></li>
        <li data-num="1"><a href="#">button 1</a></li>
    </ul>​
    

    JS:

    $('ul li').hover(function() {
        var num = $(this).data('num');
        $('li').filter(function() {
            return $(this).data('num') === num;
        }).toggleClass('hover');
    });​
    

    CSS:

    ul li.hover a {
        color: green;
    }​
    

    http://jsfiddle.net/he7Uk/2/

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

Sidebar

Related Questions

I have this trigger which works functionally (as far as I can tell by
Is there an alternative method or a trick to the hover method which can
What causes the FB.Event.subscribe event to fire? I know clicking an fb:login-button element can
Is an event handler bound to an element, so you can trigger the event
The problem im facing is: I have N IPads which can trigger an event.
I assigned x:Name in my XAML-file to a object which can trigger a MouseDown-event.
May I know know I can trigger system to repaint nth row in JList?
Can a trigger for a table can be applied for tracking in same table?
How can I trigger a stored procedure in SQL Server 2005 based on emails
In SQL Server 2005 Integration Services, how can I automatically trigger a restoration of

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.