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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:45:26+00:00 2026-05-14T02:45:26+00:00

I have a website which uses jQuery and lots of mouseover / mouseout effects.

  • 0

I have a website which uses jQuery and lots of mouseover/mouseout effects. So far I used the .bind() method of jQuery but if you have >1000 event handlers, this is slowing down your browser a lot. So, I want to move to use .live or .delegate.

One part of my portal site is a chat area. User can set chat messages which will then be displayed in a simple table. There is a feature that if you move the mouse over a chat message a trash can will appear allowing you to delete the message (if it is by you or you are a moderator).

The trash bin is in the same table cell as the chat message.

The problem: Using .bind() it worked like a charm. This is the old code:

function CreateChatMessageContextMenu(ctrl, messageID, message, sender) {
    
    var a = document.createElement("a");
    a.href = "javascript:RemoveChatMessage(" + messageID + ");"
    a.id = 'aDeleteChatMessage' + messageID;
    a.style.display = 'none';
    var img = document.createElement("span");
    img.className = "sprite-common messages-image sprite-common-btnDelete";
    a.appendChild(img);
    ctrl.appendChild(a);


    $(ctrl)
        .bind('mouseover', function(event) { $('#aDeleteChatMessage' + messageID).show() })
        .bind('mouseout', function(event) { $('#aDeleteChatMessage' + messageID).hide() });
    return;

}

‘ctrl’ is the reference to a table cell.

Now, using .live() the trashbin also appears but it is flickering a lot and when I move the mouse over the trashbin, it is disappearing or inactive. I have the feeling that more events are thrown or something. It seems like the mouseout is thrown when moving over the trashbin, but the thrashbin is inside the tablecell so mouseout should not be triggered. The new code is as follows:

$(document).ready
{
$('.jDeleteableChatMessage').live('mouseover mouseout', function(event) {
    var linkID = '#aDelete' + event.target.id;
    if (event.type == 'mouseover') {
        $(linkID).show();
    } else {
        $(linkID).hide();
    }
    return false;
});
}

function CreateChatMessageContextMenu(ctrl, messageID, message, sender) {
if (!UserIsModerator && (UserLogin != sender)) return;
ctrl.id = 'ChatMessage' + messageID;
var deleteString = 'Diese Chatnachricht löschen';
if (UserLang == '1') deleteString = 'Delete this chat message';

var a = document.createElement("a");
a.href = "javascript:RemoveChatMessage(" + messageID + ");"
a.id = 'aDeleteChatMessage' + messageID;
a.style.display = 'none';
var img = document.createElement("span");
img.className = "sprite-common messages-image sprite-common-btnDelete";
img.alt = deleteString;
img.title = deleteString;
a.appendChild(img);
ctrl.appendChild(a);

$(ctrl).addClass('jDeleteableChatMessage');

}

I add a class to tell jQuery which chat cell have a trash bin and which don’t. I also add an ID to the table cell which is later used to determine the associated trash bin. Yes, that’s clumsy data passing to an event method.
And, naturally, there is the document.ready function which initialises the .live() method.

So, where is my mistake?

  • 1 1 Answer
  • 1 View
  • 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-14T02:45:26+00:00Added an answer on May 14, 2026 at 2:45 am

    I’d use the jQuery events to prevent your flicker, they provide a bit more intelligent firing here: mouseenter and mouseleave. Keep in mind that hover is also supported on .live() now as well.

    You can use hover (mouseenter/mouseleave) like this:

    $('.jDeleteableChatMessage').live('hover', function(event) {
      $('#aDelete' + this.id).toggle();
      return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, let's start with situation. I have a website which uses Jquery 1.4.2 as
I am creating a website which uses jquery scrolling as the method of navigation
I have an existing PHP website which uses a considerable amount of jQuery and
We've built an AJAX website which uses JQuery UI extensively. we have 30+ homemade
I have an ASP.NET website which uses the jQuery dialog to present the user
I have a website which extensively uses files which are static like Jquery library,
I have a website which uses Spring Security. I have realized that when I
I have a website and a script with a for loop which uses the
I have a Silverlight web app which uses ASP.net Website administration tool for user
I have a website which uses SVG for an interactive client side thingamabob. 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.