例如,我想将链式流程分配到不同的变量中,并在不同的条件下使用它们。
var disable_btn = true;
var button_me = $('#contents.getsamplekit .sample-form .form #submit-btn-freeSample-me');
var button_disabled = button_me.attr("disabled",true).css("background","red"); // need to add more functions.
var button_enabled = button_me.removeAttr("disabled").css("background","green"); // need to add more functions here as well.
(disable_btn) ? button_disabled : button_enabled;
]
答案 0 :(得分:0)
您在分配变量时调用函数,而不是在测试disable_btn
时调用函数。如果要等待,则必须定义新功能:
function button_disable(button) {
button.attr("disabled", true).css("background", "red");
}
function button_enable(button) {
button.removeAttr("disabled").css("background","green");
}
(disable_btn ? button_enable : button_disable)(button_me);