jquery 伪类问题
我将以下脚本插入到 jquery 文件之后加载的外部文件中。代码执行正常,直到“.each”行
$("form").submit(function(event){
event.preventDefault();
var msg = fx.init();
alert($(':text').length);
$('input:text').each(function()
{
if ($(this).val == 0)
{alert('asd');
msg.append ($(this).attr('id')+" does not have a value <br />");
}
})
});
问题是“警报”部分被执行并且它显示了正确的元素数量,尽管当我查看 Opera 的 Dragonfly Errors 选项卡时显示以下消息:
1) “未知伪类第 1 行: :text" - 此消息适用于 “警报”行和
2) “未知伪 类第 1 行:输入:文本 - this 消息用于下一行
我知道我是初学者,但是你们中的任何同事都可以看到此代码中的错误吗?
fx.init() 是文件顶部的一个小对象,用于在页面中动态创建 div。
ps:此代码在 Opera 11.10 和 firefox 4 中进行了测试,结果相同,
提前谢谢您, 丹尼斯河
I have the following script inserted in an external file loaded after the jquery file. the code executes ok until the '.each' line
$("form").submit(function(event){
event.preventDefault();
var msg = fx.init();
alert($(':text').length);
$('input:text').each(function()
{
if ($(this).val == 0)
{alert('asd');
msg.append ($(this).attr('id')+" does not have a value <br />");
}
})
});
the problem is that the 'alert' part is executed and it shows the correct number of elements, although when I look in Opera's Dragonfly Errors tab is shows the following messages:
1) "Unknown pseudo class Line 1:
:text" - this message is for the
'alert' line and2) "Unknown pseudo
class Line 1: input:text - this
message is for the next line
I know I am a beginner but can any of you colleagues can see an error in this code?
the fx.init() is a small object at the top of the file to dynamically create the div into the page.
ps: this code was tested in both opera 11.10 and firefox 4 both with the same result
thank you in advance,
denis r.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,为了速度,jQuery 的选择器引擎尝试在自己的代码之前使用浏览器功能。如果浏览器不支持伪选择器,您会收到此警告。我对此不是 100% 确定,但是 其他地方也提到过类似的错误。它们只是警告,而不是错误,而且据我所知它们不会干扰任何事情。
至于你的错误, val 是一种方法,所以你需要这个:
Apparently jQuery's selector engine tries using browser functions before its own code, for speed. If a pseudo-selector isn't supported by a broswer, you get this warning. I'm not 100% sure about this, but similar errors have been mentioned elsewhere. They're just warnings though, not errors, and AFAIK they don't interfere with anything.
As for your error, val is a method, so you need this: