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

  • Home
  • SEARCH
  • 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 9130943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:03:25+00:00 2026-06-17T08:03:25+00:00

My code var post = {}; post.DivPostContent = $(‘.content’); post.DivPostContent.live({ mouseenter: function() { var

  • 0

My code

var post = {};
post.DivPostContent = $('.content');
post.DivPostContent.live({
    mouseenter:
        function()
        {
            var post_id = $(this).attr('data-post_id');
            var content_id = $('#content' + '_' + post_id);
            var link = $('#link' + '_' + post_id);
            content_id.find('.post_ratings').hide();
            content_id.find('.post_actions').show();
            //I removed the click event on a whim, i have no clue why it works
            link.unbind('click');
            link.click(function(){
                post.link_action(post_id);

            });


        },
    mouseleave:
        function()
        {
            //does something


        }
});

post.link_action = function(){
//Does some Ajax request
}

Before i unbinded the click event from “Link” it called “post.link_action” four times, i was trying to get my head around why it does that. After hours of reading through my code again and again, i thought to myself, let’s try removing the click event and i mistakenly put that line in the wrong place(out of frustration i guess). I ran the code, and viola! it worked! How? I have no clue.

Now my question is, why does unbinding the click event before adding it stop the process from repeating itself? I really would like to know why.
Thanks.

  • 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-17T08:03:26+00:00Added an answer on June 17, 2026 at 8:03 am

    because every time your mouse enter the object post.DivPostContent it’s binding a new click event to your link object; it triggered 4 times because you moused over 4 times.

    forget .live & .click; use .on instead and bind one time & outside your mouseenter event or if you insist to bind it in there use a .off before

     $elem.off("click").on("click",function() {});
    

    but do it once and outside your mousenter

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

Sidebar

Related Questions

I am using this code to post some data $('.update_btn').live(click,function() { var ID =
Please refer to the following code: var index=0; var load=0; $(td.load_ads).each(function(){ var loading=$(this); $.post('/self_coded_helpers/jpost_get_ads.php',{index:index,type:'fetch_id'},function(data){
This is the crucial code: var ajaxCallTimeoutID = null; $(document).ready(function() { $(input[id^='question']).live('keyup',function(ev){ id=this.id.substr(8); if
I have the following jQuery 1.7.2 code: var theParams = encodeURIComponent(s1)+encodeURIComponent(s2); $.post('/myURL',theParams,processData).error(errorResponse); function processData(data,textStatus){
This is my code : var xml=new String(); //function to send data every 5
I have this JS code: var recipesPost = function(name, ingredients, steps) { $.post('/api/recipes', {
I have this code: var content = $(.highlight).click(function() { $(this).html(); }).get(); $.ajax({ type :
I have the following code var email = document.getElementById(email).value; $.post(/valid,{emailadd: email},function(data){ alert(data); }); on
My flash code: var request=new URLRequest('http://localhost/test.php'); request.method = URLRequestMethod.POST; var data = new URLVariables();
I have code as follows: $(#item_select).change(function() { var params = $(#item_select option:selected).val(); $.post('/account/ar_form.php', {idata:

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.