Javascript examples for CSS Style Property:margin
Get the margins of a <div> element:
<!DOCTYPE html> <html> <head> <style> #myDiv {/* ww w . j a va2s . c o m*/ border: 1px solid #FF0000; } </style> </head> <body> <div id="myDiv" style="margin:2cm 4cm 3cm 5cm;">This is a div.</div> <br> <button type="button" onclick="myFunction()">Return margin</button> <script> function myFunction() { console.log(document.getElementById("myDiv").style.margin); } </script> </body> </html>