How to insert text in a td with id, using JavaScript

前端 未结 5 1734
情歌与酒
情歌与酒 2020-12-08 12:42

I know it may be a simple thing, but I can\'t figure out. I am trying to insert some text coming from a JavaScript function onload event into a td.



        
5条回答
  •  星月不相逢
    2020-12-08 13:13

    If your is not empty, one popular trick is to insert a non breaking space   in it, such that:

      
    

    Then you will be able to use:

     document.getElementById('td1').firstChild.data = 'New Value';
    

    Otherwise, if you do not fancy adding the meaningless   you can use the solution that Jonathan Fingland described in the other answer.

提交回复
热议问题