Why are elements null in jquery, yet exist with document.getelementbyid()

I"m trying to attached some jquery to checkboxes in a gridview, using `document.ready`: $(document).ready(function() { var chkBox= document.getElementById("gvTimeSheet_ctl01_chkAll1"); //I can alert chkBox.id, element exists var name = $("input[name='gvTimeSheet$ctl01$chkAll1']"); //Here, when I alert the id, I get a null var ID = $("#gvTimeSheet_ctl01_chkAll1"); //Here, when I alert the id, I get a null var withClass = $(".chkAll1Class"); //Here, when I alert the id, I get a null var withClass2 = $(".Bill1"); //Here, when I alert the id, I get a null //This line causes the browswer to crash and gives me the following error //Microsoft JScript runtime error: 'null' is null or not an object $("#gvTimeSheet_ctl01_chkAll1").click(function() { var checked_status = this.checked; $("input[class=Bill1]").each(function() { this.checked = checked_status; }); }); });*/ So, why are any attempts at finding an object null in jquery, yet exist in regular javascript within the same method? What am I missing here. I have the jquery js files brought in in a script tag directly above this method. I just can't seem to find any objects on this page with jquery. On other pages, I can.
Are you using any other Javascript libraries?

以上就是Why are elements null in jquery, yet exist with document.getelementbyid()的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏