我看过jQuery代码就像这样
return 13 == t.keyCode ? (t.preventDefault(), !1) : void 0
这对?
和:
意味着什么?
请给我参考,因为我还是jQuery的新手。非常感谢
答案 0 :(得分:2)
这是if else的简写:
<强>翻译强>
if(13 == t.keyCode) { return (t.preventDefault(), !1); } else { return void 0; }
答案 1 :(得分:2)
它的三元运算符。 写作if / else
的简写https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Conditional_Operator