0
在jQuery的,是有必要检查变量包含的东西或jQuery的本身做它...让我用一个例子解释:jquery:在应用效果之前验证元素是否为空...是否有必要?
var image = $(placeholder).children('img');
// if placeholder contains image, hide it!
if (image.length) {
alert('found one, hide it!');
$(image).fadeOut(400);
}
... more code here...
我已经意识到,只是写了以下的工作原理相同...
var image = $(placeholder).children('img');
$(image).fadeOut(400);
我的意思是,先做一个检查或让jquery处理它是好的做法吗?