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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:46:21+00:00 2026-05-29T11:46:21+00:00

I have an HTML table with several rows. If you hover on the row

  • 0

I have an HTML table with several rows. If you hover on the row then it displays a contextual menu which allows to add or delete the rows.

When you add the row I clone the existing row and add to the table. This works correctly! The problem is when I hover over the new row it shows the menu at the wrong position. The position is related to the row which I originally cloned! It even return the wrong top and left position which is associated with the original row which was cloned.

Any ideas!

Not sure if this is going to help but here is little bit of code:

function addOptionRow(rowToBeAdded,rowId) {

    var searchClass = "TBLCONTENTS";

    var rows = $("#" + rowId).parent().children("tr");
    var rowCount = rows.length;

    for(i=0;i<rows.length;i++) {

        if ($(rows[i]).attr('class') != searchClass && $(rows[i]).prev().attr('class') == searchClass) {

            rowToBeAdded.attr("id", getRandomString()); 
            $(rows[i]).before(rowToBeAdded.clone());
        }
    }
}

Here is the menu display code:

function OnMouseOver(obj) { // obj is row which is passed in

    var top = 0;
    var left = 0;
    var id = "#" + obj.id;   

    currTemplateRow = obj.parentElement.parentElement;

    var pos = $(id).position();
    top = pos.top - 5;
    left = pos.left - 5;

    $("#menuToolsetTemplate").css(
            { position: "absolute",
                top: top + "px",
                left: left + "px"
            }
        ).show();  

}
  • 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-29T11:46:23+00:00Added an answer on May 29, 2026 at 11:46 am

    I tried to simulate what you are doing and it works fine for me.. Check my jsFiddle DEMO. Onclick on each row it clones that row and appends it to the bottom. JSBin DEMO

    As I mentioned in the comment, the obj that is being passed in your function OnMouseOver(obj) is not the correct row. You code doesn’t tell us where or how this mouse over function is binded to hover(mouseover and mouseout) event.

    JS:

    var index = 0;
    $('#mytable tr').on ('click', function () {
        var $this_cloned = $(this).clone();
        $this_cloned.attr('id', this.id + (index++));
        $('#mytable tr:last').after($this_cloned);  
    });
    
    $('#mytable').on ('mouseenter', 'tr', function () {
        var top = 0;
        var left = 0;
        var id = "#" + this.id;   
    
        //currTemplateRow = obj.parentElement.parentElement;
        var pos = $(id).position();
        top = pos.top - 5;
        left = pos.left - 5;
    
        $("#menu").text ('Menu for ' + this.id);
    
        $("#menu").css(
                { position: "absolute",
                    top: top + "px",
                    left: left + "px"
                }
            ).show();  
    });
    
    $('#mytable').on ('mouseleave', 'tr', function () {
        $("#menu").hide();
    });
    

    HTML

    <table id="mytable" cellpadding="0" border="1px" >
        <tr id="row1" >
            <td>Row 1</td>
            <td>Row 1</td>
            <td>Row 1</td>
        </tr>
        <tr id="row2" >
            <td>Row 2</td>
            <td>Row 2</td>
            <td>Row 2</td>
        </tr>   
        <tr id="row3" >
            <td>Row 3</td>
            <td>Row 3</td>
            <td>Row 3</td>
        </tr>
    </table>
    <div id="menu">Menu</div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HTML table with several columns and several rows. The last row
I have a html table which has several rows - lets say 17 for
I have a simple html table which has several rows. the following is implemented
I have an html table with many rows. I'm currently grouping several rows inside
I have an HTML Table consisting of several rows. I am trying to insert
I have an HTML table with several columns and I need to implement a
I have an html table which i bind data dynamically on the server side
I have a HTML table like this: <table border=1> <tbody> <tr> <td><a href=# class=delete>DELETE
I have a HTML table like this: <table border=1> <tbody> <tr> <td><a href=# class=delete>DELETE
I have an HTML table with a large number of rows, and I need

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.