首页
极刻
圈子
教程
开源
登录 / 注册
返回教程:Javascript 参考手册
TRY RUN / 在线示例
Javascript 参考手册 尝试一下
Javascript 参考手册 尝试一下
源代码
运行
<!DOCTYPE html> <html> <head> <style type="text/css"> div { border: 1px solid #FF0000; } </style> <script> function changeMargin() { document.getElementById("ex1").style.marginRight="100px"; } function changePadding() { document.getElementById("ex2").style.paddingRight="100px"; } </script> </head> <body> <div id="ex1">This is some text. This is some text. This is some text. This is some text. This is some text.</div> <br> <button type="button" onclick="changeMargin()">Change right margin of the div element</button> <br> <br> <div id="ex2">This is some text. This is some text. This is some text. This is some text. This is some text.</div> <br> <button type="button" onclick="changePadding()">Change right padding of the div element</button> </body> </html>
运行结果