Tag: 简写

JavaScript中&&简写的解释

使用jQuery的水印插件,我正在尝试jslint并最小化函数,但我遇到了我从未见过的语法,其中有表达式,其中确实应该有一个赋值或函数调用: (function($) { $.fn.watermark = function(css, text) { return this.each(function() { var i = $(this), w; i.focus(function() { w && !(w=0) && i.removeClass(css).data(‘w’,0).val(”); }) .blur(function() { !i.val() && (w=1) && i.addClass(css).data(‘w’,1).val(text); }) .closest(‘form’).submit(function() { w && i.val(”); }); i.blur(); }); }; $.fn.removeWatermark = function() { return this.each(function() { $(this).data(‘w’) && $(this).val(”); }); }; })(jQuery); 我对以下几行特别感兴趣: […]