源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <script> function setSpace(){ document.getElementById("compman").hspace="50"; document.getElementById("compman").vspace="50"; } </script> </head> <body> <img id="compman" src="/images/logo.png" alt="Computerman" width="107" height="98"> <p>一些文本。一些文本。一些文本。一些文本。</p> <input type="button" onclick="setSpace()" value="設置水平和垂直間距"> </body> </html>
運行結果