开发者

Object expected error

My site is working perfectly in all browsers except the IE. The error box is prompted when the page is load in IE with the error msg below: Line: 227 Error: Object expected

when i start debugging, the error is from here below at the first line.

$().ready(function()
{
    // Hide all elements with .hideOnSubmit class when parent form is submit
    $('form').submit(function()
    {
        $(this).find('.hideOnSubmit').hide();
    });
});

Can anyone advice? it is really an开发者_StackOverflow社区noying to prompt that message on every page

============== EDIT ===============

I have tried the advice below

$(document).ready(function($)
{
    // Hide all elements with .hideOnSubmit class when parent form is submit
    $('form').submit(function()
    {
        $(this).find('.hideOnSubmit').hide();
    });
});

OR

jquery(function($)
{
    // Hide all elements with .hideOnSubmit class when parent form is submit
    $('form').submit(function()
    {
        $(this).find('.hideOnSubmit').hide();
    });
});

But both also give me the same error.


Either use

$(document).ready(function() { … } );

or

jQuery(function($) { … } );


Does your form have a control with a name or id iof submit? If so, it is shaddowing the submit method of the form.

Change it to something else, like "submitButton", or if you don't need to reference it or post it with the form, don't give it a name or id at all.


Try this.

jQuery(function($) {
    $('form').submit(function() {
        var elm = $(this).find('.hideOnSubmit');
        if (elm.length) {
            elm.hide();
        }
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜