本文實例講述了JS實現控制表格行文本對齊的方法。分享給大家供大家參考。具體如下:
下面的JS代碼可以控制表格內的整行文本向左或者向右對齊
<!DOCTYPE html><html><head><script>function leftAlign(){document.getElementById('header').align="left";}</script></head><body><table width="100%" border="1"><tr id="header"><th>Firstname</th><th>Lastname</th></tr><tr><td>Peter</td><td>Griffin</td></tr></table><br><input type="button" onclick="leftAlign()" value="Left-align table row"/><p><b>Note:</b> This example does not work in Internet Explorer.</p></body></html>
希望本文所述對大家的javascript程序設計有所幫助。
新聞熱點
疑難解答