编辑下面的代码:【加编码】
<html> <head> <style type="text/css"> div { border: 1px solid #FF0000; } </style> <script> function changeMargin() { document.getElementById("ex1").style.margin="100px"; } function changePadding() { document.getElementById("ex2").style.padding="100px"; } </script> </head> <body> <div id="ex1">This is some text.</div> <br> <button type="button" onclick="changeMargin()">Change margin of the div element</button> <br> <br> <div id="ex2">This is some text.</div> <br> <button type="button" onclick="changePadding()">Change padding of the div element</button> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂