jQuery:如何让智能感知在缓存元素上工作
我怎样才能让 jQuery Intellisense 处理缓存的元素。如果我执行以下操作,我不会得到智能感知:
var elem = $j('#elemID');
elem.height(100);
如果我将上面的代码更改为以下代码,那么我就有了智能感知,但这是正确的方法吗?我不是从 jQuery 对象重新创建 jQuery 对象吗?
var $(elem) = $j('#elemID');
$(elem).height(100);
How could I get jQuery Intellisense working on cached Elements. If I do the following, I get no Intellisense:
var elem = $j('#elemID');
elem.height(100);
If I change the code above to the followung, than I have intellisense, but is that the right way? Am I not recreating a jQuery objectfrom a jQuery object?
var $(elem) = $j('#elemID');
$(elem).height(100);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来我现在有了 Intellisense,诀窍是用 $ 开始 jQuery-Object 的变量名。
这样做可以让我智能感知并更好地区分缓存的 jQuery 对象和普通对象/变量: $elem 是 jQuery 对象, height 只是普通变量/数字。
Well it appears that I got Intellisense now, the trick is to start the variable names for jQuery-Object with $.
Doing this gives me intellisense and a better distinction between cached jQuery-objects and normal objects/variables: $elem is a jQuery-object and height just a normal variable / number.