jquery issue with pseudo class
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 and
2) "Unknown pseudo class Line 1: input:text - this message is for the next line
I know I am a beginner b开发者_高级运维ut 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.
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:
if ($(this).val() == 0)
精彩评论