2

This is a simple jQuery code, what I want to do is hide #bling, but it does not

<script language="javascript">

 $("document").ready(function() {  

      $('#bling').hide();  


  }); 

</script>

<div id="bling" style="background-color:#FFFF66; width:100px; height:100px;"></div> 

Thanks Dave

3
  • 1
    This shouldn't affect this piece of code, but language should probably be somethinglike language="text/javascript" Commented Jan 25, 2010 at 8:07
  • 1
    That code works fine in Firefox and IE8. Are you sure you have Jquery loaded? Commented Jan 25, 2010 at 8:08
  • 5
    @anonymous: the value for the language property is correct. It is however better to use type="text/javascript" Commented Jan 25, 2010 at 8:08

6 Answers 6

9

Change $("document") to $(document)

Sign up to request clarification or add additional context in comments.

2 Comments

Are you including jQuery in your HTML?
'<script language="javascript"> $(document).ready(function() { $("#bling").hide(): }); </script> <div id="bling" style="background-color:#FFFF99; width:200px; height:100px;">test</div>' Check the above out
3

I tested the code, and it works fine, eventhough you have the string "document" instead of document and an ancient language attribute on the script tag...

Use type="text/javascript" on the script tag. You can just send a function to the jQuery object as a shortcut for using the ready function:

<script type="text/javascript">

$(function(){
   $('#bling').hide();
});

</script>

However, as it's not this code that is the problem, there is something else in your page that is causing it.

  • Check that you have successfully included the jQuery script.

  • Check that you don't have another element with the id "bling". An id has to be unique in the page.

  • Check for Javascript error messages. In IE check the status bar for a notification. In Firefox open the Javascript console.

Comments

1

Works for me as it is . Try using jquery from jquery site, the code is below.

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script language="javascript">

 $("document").ready(function() {  

      $('#bling').hide();  


  }); 

</script>

<div id="bling" style="background-color:#FFFF66; width:100px; height:100px;">aaaaaaaa</div>

See if it works.

1 Comment

Note: It's not including the script from the jQuery site, it's including it from the Google site.
0

Change:

$("document").ready(function() {

//..to..

$(function() {

Comments

0

Make sure you are including the jQuery core javascript file in your HTML. On top of that, your code should look more like this:

<script type="text/javascript">
$(document).ready(function() {  
   $('#bling').hide();  
}); 
</script>

Note the type attribute on the script tag as well as document not in quotes.

1 Comment

<script language="javascript" type="text/javascript"><br /> $(document).ready(function() { $('#album_result').hide(); }); </script> <div id="album_result" style="background-color:#FFFF99; width:200px; height:100px;">test</div>
0

Make sure jQuery is loading:

<script language="javascript">

 $(document).ready(function() {  

      alert('Can you hear me now?');
      //$('#bling').hide();  


  }); 

</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.