jQuery: how to access parent function “this” from inside anonymous function?

前端 未结 5 874
余生分开走
余生分开走 2020-12-28 16:07
...
$.fn.annotateEdit = function(image, note) {
    if (note) {
        this.note = note;
    } else {
        var newNote = new Object();
        newNote.id = \"new         


        
5条回答
  •  被撕碎了的回忆
    2020-12-28 16:31

    Check this - http://api.jquery.com/bind/ and "Passing event data" You can do something like this :

    form.find(':radio').bind("change", {
    context : this
    }, function(event){
        console.log(event.data.context);
        console.log(event.data.context.note);
    });
    

提交回复
热议问题