Home >Web Front-end >Front-end Q&A >How to modify table value in javascript

How to modify table value in javascript

藏色散人
藏色散人Original
2021-07-03 09:40:482589browse

How to modify the table value in javascript: first open the corresponding front-end code file; then find the js code part; finally modify the value of td in the table through the "function getTdDirectly(){...}" method.

How to modify table value in javascript

The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.

How to modify table value in javascript?

js changes the value of td in the table

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<table id=&#39;mytable&#39;>
<tbody>
<tr>
<td id=&#39;mytd&#39;>这里是td的值</td>
</tr>
</tbody>
</table>
<br />
<input type=&#39;button&#39; value=&#39;绝对路径获取td的值&#39; οnclick=&#39;getTdDirectly()&#39; />
<script>
function getTdDirectly(){
var tdobj = document.getElementById(&#39;mytd&#39;);
tdobj.innerText = "ssss";
 
}
 
 
</script>

Recommended study: "javascript Advanced Tutorial"

The above is the detailed content of How to modify table value in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn