0

我想在 jQuery 中运行函数,但是在它完成后更改/重新定义这个函数。

jsFiddle 示例

HTML

<div id="test">TEST</div>

jQuery

function yes() {
    alert('yes');

    // I dont know how, but i mean something like :
    //this.fn.function yes(){ 
    //   alert('no');
    //};
};

$('#test').click(function () {
    yes();
});
4

2 回答 2

5
function yes() {
    alert('yes');

    yes = function(){alert('no');};
};
于 2013-08-08T08:23:58.663 回答
0

FIDDLE

It would be better if you try to explain what the exact purpose for this is. As for your current question, create another function to do that

function yes() {
   alert('yes');

    no();
};

function no(){
   alert('no');
}

 $('#test').click(function () {
    yes();
 });
于 2013-08-08T08:34:34.173 回答