VeecoTech
VeecoTech

Reputation: 2143

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 annoying 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.

Upvotes: 0

Views: 686

Answers (3)

codeandcloud
codeandcloud

Reputation: 55210

Try this.

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

Upvotes: 0

RobG
RobG

Reputation: 147403

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.

Upvotes: 0

Sebastian Wramba
Sebastian Wramba

Reputation: 10127

Either use

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

or

jQuery(function($) { … } );

Upvotes: 4

Related Questions