jQuery空选择器(空选择器)
问题描述:
有时,构建项目集合时,有一个空的jQuery对象是有用的,既可以用作默认值,也可以用作初始值。jQuery空选择器(空选择器)
有关示例,请参阅here。
做到这一点的一种方法是使用不太可能匹配任何东西的选择器,如$('skdhjfksjdhfksjhdf')
,但这显然不雅观。
如何获得优雅风格的空jQuery对象?
答
你的意思是......
//just get jQuery...
var foo = $();
//or just get the browser using jQuery...
if($.browser.msie){
alert('You are using the blue e!');
}
您需要一个空白选择器的位置? – Randell 2009-08-04 16:18:43
你想做什么? – 2009-08-04 16:18:45