试图找出在Jquery命令序列中插入条件的方法。 基本上我的观点是我可以保存代码长度。命令序列中的条件
例子:
var first=true;
if(first){
ap.nextAll("div").first()....
}else{
ap.nextAll("div").last()....
}
,是否可以做这样的事情:
ap.nextAll("div").(first?first():last())....
这是我知道,它可以解决: last
唯一的例子,但它只是作为一个例子。
感谢Pesulap
什么是你的问题来吗? –
我可能会描述一下,对吧? – Pesulap
[调用JavaScript对象方法与变量]的可能重复(http://stackoverflow.com/questions/6737840/call-javascript-object-method-with-a-variable) – Barmar