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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:24:28+00:00 2026-06-04T16:24:28+00:00

Basically, I want to append a div to an li element on mouseenter, then

  • 0

Basically, I want to append a div to an li element on mouseenter, then append a separate div on mouseenter of another li element of the same parent ul. So if an li is hovered, append #div1, then if another li is hovered, append #div2.

This is what I have so far

$('ul > li').mouseenter(function (){
      $('#div1').appendTo(this);

      if (('ul > li').mouseenter().not(this)){
         $('#div2')appendTo(this);
      }
});

This only appends #div1 to the hovered li. How do I append #div2 if another li is hovered? The .not() selector doesn’t seem to be working. Thanks in advance.

  • 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-04T16:24:30+00:00Added an answer on June 4, 2026 at 4:24 pm

    I’d suggest the following:

    $('li').mouseenter(
        function(){
            var that = $(this),
                i = that.index();
            if (i == 0){
                $('#div1').appendTo(that);
            }
            else {
                $('#div2').appendTo(that);
            }
        });
    

    The above is based on the assumption that you wish to append #div1 to the first li, and #div2 to all other li elements.


    Edited in response to comment from OP (left below):

    I actually want to append #div1 on mouseenter then if another li is hovered, i’d like to append #div2 to the same li that #div1 was appended to.

    $('li').mouseenter(
        function(){
            var that = $(this),
                i = that.index();
            if (i == 0){
                $('#div1').appendTo(that);
            }
            else {
                $('#div2').appendTo($('#div1').closest('li'));
            }
        })
    

    References:

    • appendTo().
    • closest().
    • index().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I basically just want to append a javascript variable to an HTML div with
I basically want to do this in code: PersonList myPersonList; //populate myPersonList here, not
I basically want to be able to deploy multiple versions of the same EAR
Basically, I have one div(divNew) which is being populated with content from another page(thread.php)
Basically I have a one-to-many table. I want to append the columns of the
Basically, I want to get chars from EditText s and append TextView s text.
I basically want to make things easier by just looping LinkButtons instead of making
I basically want to open a browser window from Word using VBA that does
I basically want to know what the system's input language is currently on (for
I just basically want to add about 20 and sometimes 80 Proximity Alerts with

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.