asp.net - how to change id of table cell using javascript - Stack Overflow

I have tried this, but not working.tbl1.rows[0].cells[0].id ='myId';and this is also not work

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 badges
Add a ment  | 

3 Answers 3

Reset to default 3

This 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信