Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

jquery document.ready $("#controlId") is null error

I'm working on a script that uses jquery and it's working normally on a simple page that I made. However when I create a master page in c# and put the jquery code in the page that extends the master page I get this error:

$("#controlId") is null error
My javascript structure inside the page:
<script language="javascript" type="text/javascript">
$(document).ready(
  function() {
    alert($("#controlId")); //this will return null
  }
);
</script>

//solution, get the no conflict version

<script language="javascript" type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(
  function() {
    alert($j("#controlId")); //object is properly initialized
  }
);
</script>
jquery document.ready $("#controlId") is null error jquery document.ready $("#controlId") is null error Reviewed by Edward Legaspi on Wednesday, February 02, 2011 Rating: 5

No comments:

Powered by Blogger.