I have tried this, but not working.
tbl1.rows[0].cells[0].id ='myId';
and this is also not working
tbl1.rows[0].cells[0].setAttribute("id","newid");
how can I do this?
EDIT: When view the page source the id is not changed, but when we check using Firebug, then there is shown new Id.
Thanks
I have tried this, but not working.
tbl1.rows[0].cells[0].id ='myId';
and this is also not working
tbl1.rows[0].cells[0].setAttribute("id","newid");
how can I do this?
EDIT: When view the page source the id is not changed, but when we check using Firebug, then there is shown new Id.
Thanks
Share Improve this question edited May 8, 2010 at 5:47 Muhammad Akhtar asked Apr 29, 2010 at 7:05 Muhammad AkhtarMuhammad Akhtar 52.2k37 gold badges139 silver badges191 bronze badges3 Answers
Reset to default 3This should work. If it isn't then there might be an error somewhere else or the selector is not the correct one.
See a working demo.
Edit
Just found that this doesn't work in firefox.
Try
document.getElementById("tbl1").rows[0].cells[0].id = "myId";
Are you sure tbl1.rows[0].cells[0]
is defined? Because if it is a valid DOM element, then simply setting the id
property should be enough.
If tbl1 points to an existing table DOM element then this should work. Are you waiting for the page to load before assigning to tbl1? Perhaps tbl1 is not getting assigned as intended.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744858069a4597528.html
评论列表(0条)