disable function after execute

  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

Is it possible to disable or remove a function after it's been executed?

I have a function that executes on mouseover of a div. After it's been executed; I want an entirely different function to execute on mouseover. How do I disable the initial function so it doesn't interfere with my next function?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

I would say after the first mouse over you change the onmouseover event. Are you using raw Javascript or a framework?
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

framework, jquery
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

This should work

Code: [ Select ]
$(document).ready(function() {
    $('#target').bind('mouseover', function() {
        alert('Handler for mouseover called.');
        
        $(this).unbind();
        $(this).bind('mouseover', function() {
            alert('New handler for mouseover called.');
        });
     
    });


    
});
  1. $(document).ready(function() {
  2.     $('#target').bind('mouseover', function() {
  3.         alert('Handler for mouseover called.');
  4.         
  5.         $(this).unbind();
  6.         $(this).bind('mouseover', function() {
  7.             alert('New handler for mouseover called.');
  8.         });
  9.      
  10.     });
  11.     
  12. });

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 127 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.