Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/438.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript更改td内容html表_Javascript_Html Table_Tr - Fatal编程技术网

使用javascript更改td内容html表

使用javascript更改td内容html表,javascript,html-table,tr,Javascript,Html Table,Tr,我有这个HTML代码,我想使用Javascript更改表td内容(使用新内容而不是旧内容)。 我怎么做 <table> <tr> <td><label class='A' >A:</label> </td> <td class='myClass'/>Old Content</td> </tr> </table> A: 旧内容

我有这个HTML代码,我想使用Javascript更改表td内容(使用新内容而不是旧内容)。 我怎么做

    <table>
    <tr>
    <td><label class='A' >A:</label> </td>
    <td class='myClass'/>Old Content</td> 
    </tr>
    </table>

A:
旧内容
琐碎的:

var-element=document.querySelector('.myClass')
//如果您的内容仅包含文本:
element.textContent='新内容'
//如果您的内容包含更复杂的标记:
element.innerHTML='新内容'

A:
旧内容

您已经了解了哪些内容,能否给出一个输出示例?