no

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

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>

Related

web 1955980683322501201

Post a Comment

item