Why is document.getElementById('tableId')[removed] not working in IE8?

前端 未结 8 2049
迷失自我
迷失自我 2020-12-01 14:17

I modify document.getElementById(\'\').innerHTML with Java Script in a page. It\'s working fine in Firefox, but not IE8. Please see below for more details:

相关标签:
8条回答
  • 2020-12-01 14:47

    I believe IE behaves strangely when you play with the innerHTML of tr elements. I would select the row with getElementById, and then select the td and alter that one's innerHTML:

    document.getElementById('abc').firstChild.innerHTML = 'abc';
    

    (Though you have to be careful with this: often the whitespace between the tr and the td will be considered a valid node)

    There's a whole heap of special functions for working with tables in the DOM

    var tblBody = document.getElementById(tblId).tBodies[0];
    var newRow = tblBody.insertRow(-1);
    var newCell0 = newRow.insertCell(0);
    

    See all the functions here: http://www.mredkj.com/tutorials/tablebasics1.html

    0 讨论(0)
  • 2020-12-01 14:53

    Thanks its very helpful .html()

    I was using

    document.getElementById('site'+cValue).innerHTML=tableReadyElem; //work with mozila not ie
    
    $(document.getElementById('site'+cValue)).html(tableReadyElem);//work for both
    
    0 讨论(0)
提交回复
热议问题