编辑下面的代码:【加编码】
<html> <head> <script> function displayResult() { document.getElementById('td1').vAlign="top"; document.getElementById('td2').vAlign="top"; document.getElementById('td3').vAlign="top"; } </script> </head> <body> <table width="50%" border="1"> <tr> <th>Firstname</th> <th>Lastname</th> <th>Text</th> </tr> <tr> <td id="td1">Peter</td> <td id="td2">Griffin</td> <td id="td3">Hello my name is Peter Griffin. I need a long text for this example. I need a long text for this example.</td> </tr> </table> <br> <button type="button" onclick="displayResult()">Top-align content</button> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂