jQuery求解释disabled = !!object.disabled 是什么意思呢??
完整代码:
var addEvents = function(object){
var checked = object.checked;
var disabled = object.disabled;
var $object = $(object);
if ( object.stateInterval )
clearInterval(object.stateInterval);
object.stateInterval = setInterval(
function()
{
if ( object.disabled != disabled )
$object.trigger( (disabled = !!object.disabled) ? 'disable' : 'enable');
if ( object.checked != checked )
$object.trigger( (checked = !!object.checked) ? 'check' : 'uncheck');
},
10 /* in miliseconds. Low numbers this can decrease performance on slow computers, high will increase responce time */
);
return $object;
};
这样的目的是保证返还的是true or false
如当 object.disabled 等于 NaN,null, undefined,""等等时,直接disabled = object.disabled
disabled还是NaN等
用了!!就保证了disabled不是true就是false