function testit(){
document.getElementById("th1").style.textAlign = "right";
}
#th1{
text-align:left;
}
<table>
<tr><center><th colspan="2" id="th1">EmergencyImportantContactsnumbers</th><center></tr>
<tr><th colspan="2" id="th1" >Emergency.SQUCampus</tr></tr>
<tr><th>Emergency.m1</th><th id="th1" >Emergency.m2</th><tr>
<tr><td>Emergency.m3</td><td id="th1" >Emergency.m4</td></tr>
<tr><td>Emergency.m5</td><td id="th1" >Emergency.m6</td></tr>
</table>
<button onclick="testit();">Text Script</button>
I want to change the text align of cell in table. i have used javascript for changing the text align. When i re edit the style code it is not working.
I want to change th1 text alignment to right. But my code is not working. Please help me thank u.