那些js中的高逼格的简写
判断元素是否存在
if($(".robot").length)$(".robot").dance();
代替if,适合简短没有else的情况
$(".robot").length && alert(1);
三目代替if..else
$(".robot").length ? alert(1) : alert(2);
$(".robot").length ? alert(1) : null;
判断元素是否存在
if($(".robot").length)$(".robot").dance();
代替if,适合简短没有else的情况
$(".robot").length && alert(1);
三目代替if..else
$(".robot").length ? alert(1) : alert(2);
$(".robot").length ? alert(1) : null;