【发布时间】:2013-03-23 06:23:49
【问题描述】:
$("<button>")
.addClass("radio")
.addClass(this._getValue(lbl) ? "checked" : "")
.attr(this._getDisableProp(lbl) ? ("disabled", "disabled") : "")
.prop(this._getDisableProp(lbl) ? ("disabled", true) : ("disabled", false));
在上面的代码中,我试图添加 attr 和 prop 仅当我的函数返回 true 时。我对addClass 做了同样的事情,它有效,但它不适用于attr 和prop。
请问有什么解决办法吗?
【问题讨论】: