开发者

how to set an id with some value in of td in javascript

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 wa开发者_如何学JAVAnt to set id of the td with value example plz help


cell5.id = 'example1'; // javascript

I suppose we're talking about IE here? I don't know about "id", but..

http://webbugtrack.blogspot.com/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 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜