How do you assign event to an object that is within the function you want it assigned to?

Discussion in 'jQuery' started by gandalf117, Nov 14, 2013.

  1. #1
    Let's say you have something like this:

    var clickHandler = function() {
    
        var link = $('<span></span>');
    
        someElement.append(link);
    
        link.click (clickHandler); ???
    
    }
    Code (markup):
    Is there a way to append the function the the link is in as an action of that link?

    I know that the example above is going to result in a recursive endless loop. I don't intend to use it like this. I just give this as an example.
     
    gandalf117, Nov 14, 2013 IP