W3School TIY
编辑您的代码:
<html> <head> <script type="text/javascript"> function changeMargin() { document.getElementById("p1").style.margin="100px"; } </script> </head> <body> <input type="button" onclick="changeMargin()" value="Change margins of a paragraph" /> <p id="p1">This is a paragraph</p> </body> </html>
查看结果: