P.Brian.Mackey
P.Brian.Mackey

Reputation: 44275

jQuery - hide a span on document.ready

I want to hide a span on document.ready. I tried

<script type="text/javascript">
    //Set the stuff we want to be able to use in javascript, but not display in the browser window invisible
    $(document).ready(
        function () {
            ('#_ctl0_ContentPlaceHolder1_lType').hide()
        });
</script>

But, I get error "Object doesn't support this property or method" in IE7 debugger. I verified in the source that the object exists as a <span> and the id is correct.

Upvotes: 1

Views: 17352

Answers (3)

Naftali
Naftali

Reputation: 146302

Try this:

    $(document).ready(function () {
        $('#_ctl0_ContentPlaceHolder1_lType').hide();
    });

You left off the $.

Upvotes: 7

Pekka
Pekka

Reputation: 449395

It doesn't seem to be the root of your problem, but note that _ is an invalid starting character for an ID.

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

Upvotes: 0

Chandu
Chandu

Reputation: 82893

You are missing a $ infront of the span selector. Try this:

<script type="text/javascript">     
 //Set the stuff we want to be able to use in javascript, but not display in the browser window invisible     
 $(document).ready(function () {             
   $('#_ctl0_ContentPlaceHolder1_lType').hide();
 }); 
</script> 

Upvotes: 3

Related Questions