views:

144

answers:

4

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

+2  A: 
rahul
have you check your link in Firefox?
Muhammad Akhtar
Also can you view source after changing, you will not see there? however if click on get, it will return the change id
Muhammad Akhtar
View Source shows you the original, not the current state of the source.
Max Shawabkeh
Check the new code and then inspect in FF.
rahul
still no success, plz check at your end.
Muhammad Akhtar
The example still uses `tbl1` as a global variable, which is a wrongness that only works on IE. The version with `document.getElementById` works.
bobince
A: 

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.

Max Shawabkeh
yes, I am access this alert(tbl1.rows[0].cells[0].className);
Muhammad Akhtar
A: 

use jquery http://api.jquery.com/category/attributes/ i think jquery attributes will help you

Waleed Mohamed
A: 

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.

Stephane Moore