我「米試圖附加了一些jQuery來在GridView複選框,使用document.ready
存在:爲什麼在jQuery的空元素,但通過document.getElementById()
$(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;
});
});
});*/
那麼,爲什麼在發現任何嘗試jquery中的對象爲null,但在同一個方法中存在於普通的javascript中?我在這裏丟失了什麼。我在這個方法的正上方有一個腳本標記中引入了jquery js文件,我似乎無法找到任何對象在其他頁面上,我可以。
您是否在使用任何其他Javascript庫? – 2009-08-11 18:56:30
你能發佈生成的HTML源代碼嗎?也許在http://jsbin.com/上發佈一個沙箱將有助於理解。 – 2009-08-11 18:58:15
你如何提醒身份證? – womp 2009-08-11 18:58:31