Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Dec 2008
    Posts
    117
    Thanks
    14
    Thanked 0 Times in 0 Posts

    jquery: unbind or remove a function

    Hi,
    how can I unbind or remove a function with jquery?

    for instance, this is my html,

    Code:
    <li><img src="..." alt="1"></li>
    <li><img src="..." alt="2"></li>
    <li><img src="..." alt="3"></li>
    <li class="padlock"><img src="..." alt="4"></li>
    i will display the value of alt with the tooltip code below,

    Code:
    $(document).ready(function(){
       tooltip();
    });
    
    
    this.tooltip = function(){	
    			
    		xOffset = 10;
    		yOffset = 20;		
    				
    	$("li").hover(function(event){											  
    		var title = $(this).find("img").attr("alt");									  
    		$("body").append("<p id='tooltip'>"+ title +"</p>");
    		$("#tooltip")
    			.css("top",(event.pageY - xOffset) + "px")
    			.css("left",(event.pageX + yOffset) + "px")
    			.fadeIn("fast");		
        },
    	function(){	
    		$("#tooltip").remove();
        });	
    	$("li").mousemove(function(event){
    		$("#tooltip")
    			.css("top",(event.pageY - xOffset) + "px")
    			.css("left",(event.pageX + yOffset) + "px");
    	});			
    };
    i want to remove this tooltip function when the class 'padlock' is clicked,

    Code:
    $('.padlock').click(function(){	
    	$(this).append("<li class=\"locked\"></li>");
    	$('.padlock').unbind('mouseenter mouseleave');
    	$('.padlock').unbind('click');
    	$(".unlocked").remove();
    	$(this).addClass('currentlock');
    	removeMouseover();
    	lockoff();
    	});
    many thanks,
    Lau

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Come on now, this is the exact same question, and you never even cared to reply or thank the people that helped you.

  • #3
    Regular Coder
    Join Date
    Dec 2008
    Posts
    117
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by venegal View Post
    Come on now, this is the exact same question, and you never even cared to reply or thank the people that helped you.
    it is different actually from that thread.

    the older one is a question to remove 'events'

    and this question here is how i can remove 'functions'

    thanks,
    L

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    A function does nothing unless it's called from some sort of event, so if you remove the event that calls the function, isn't that good enough?

  • #5
    Regular Coder
    Join Date
    Dec 2008
    Posts
    117
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    A function does nothing unless it's called from some sort of event, so if you remove the event that calls the function, isn't that good enough?
    it has other functions in the particular event i need to keep...

  • #6
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Be that as it may, you never replied in the other thread, and I find that very impolite. People are investing their time to help you, and not getting any feedback on the help is frustrating.

    So, short answer for you: RTM. You pass the function as the second parameter to unbind.

  • #7
    Regular Coder
    Join Date
    Dec 2008
    Posts
    117
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by venegal View Post
    Be that as it may, you never replied in the other thread, and I find that very impolite. People are investing their time to help you, and not getting any feedback on the help is frustrating.

    So, short answer for you: RTM. You pass the function as the second parameter to unbind.
    thanks. i could forget to reply sometimes. and others i simple dont understand on the answers have given or suggested.

    i try to post all my codes which i receive helps from the forums around - i could leave out some threads...

    http://lauthiamkok.net/tmp/gtclients/1/

    thanks,
    L


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •