Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
56
rated 0 times [  62] [ 6]  / answers: 1 / hits: 18515  / 11 Years ago, thu, march 28, 2013, 12:00:00

I have DIV and inside div it has table. I want to change the one of the column value of table using java script. I can do it by getting the element id of column, but there is no any id assigned to any table's column. Below is the example.



<div id=usersec>
<TABLE style=TEXT-ALIGN: center; WIDTH: 279px; HEIGHT: 70px>
<TBODY>
<TR>
<TD style=FONT-FAMILY: Verdana vAlign=center align=middle>Talk to me </TD></TR></TBODY></TABLE>
</div>


Is it possible to change the Talk to me text using javascript?


More From » html

 Answers
40

Yes, you need to get the element and then set a new value to element.innerHTML. It's easiest if you give an id to the element that you want to change but you don't need to



jsFiddle



<script type=text/javascript>
var usersec = document.getElementById('usersec');
var td = usersec.getElementsByTagName('td')[0];
td.innerHTML = 'New value';
</script>

[#79269] Wednesday, March 27, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hakeemabramh

Total Points: 234
Total Questions: 109
Total Answers: 109

Location: Romania
Member since Mon, Jun 6, 2022
2 Years ago
;