tags:

views:

93

answers:

7

Hello,

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

+7  A: 

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

Jan Hančič
Removing that does not help
Jean
Are you including jQuery in your HTML?
Jan Hančič
'<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
Jean
Yes I got the jquery done, and I am using chrome
Jean
A: 

Change:

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

//..to..

$(function() {

wharsojo
Does not work either, this is getting real weird
Jean
A: 

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.

Dominic Barnes
<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>
Jean
+3  A: 

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.

Guffa
A: 

It for some reason, worked now. Thanks guys...

Jean
A: 

Make sure jQuery is loading:

<script language="javascript">

 $(document).ready(function() {  

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


  }); 

</script>
Paperjam
A: 

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.

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