i m creating td in javascript what i want is this "<td id='abc'>"
how can i set the td id in javascript i use setAtteribute()
not working
my code look like this
var cell4 = row.insertCell(3);
cell4.innerHTML = "Song";
var cell5 = row.insertCell(4);
cell5.setAttribute('id','example1');
i want to set id of the td with value example plz help
i m creating td in javascript what i want is this "<td id='abc'>"
how can i set the td id in javascript i use setAtteribute()
not working
my code look like this
var cell4 = row.insertCell(3);
cell4.innerHTML = "Song";
var cell5 = row.insertCell(4);
cell5.setAttribute('id','example1');
i want to set id of the td with value example plz help
Share Improve this question edited Jul 27, 2010 at 10:42 kennytm 524k110 gold badges1.1k silver badges1k bronze badges asked Jul 27, 2010 at 10:40 user403269user403269 912 gold badges2 silver badges3 bronze badges3 Answers
Reset to default 3cell5.id = 'example1'; // javascript
I suppose we're talking about IE here? I don't know about "id", but..
http://webbugtrack.blogspot./2007/08/bug-242-setattribute-doesnt-always-work.html
Using javascript
(w/o jquery)
cell4.id="some_td_id"
for example
advTable=document.getElementById("advance_option");
advRow = advTable.insertRow(advTable.rows.length);
advRow.id ="tr_id" // Here you can set tr's id
cell0=advRow.insertCell(0);
cell0.id="td_id" // Here you can set td's id
cell1=advRow.insertCell(1);
cell5.attr("id","example1"); //jquery