Javascript DOM CSS Style paddingLeft Property set

Introduction

Change the left padding of a <div> element back to "normal":

document.getElementById("myDiv").style.paddingLeft = "0px";

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {/*  www.  j  a v a 2 s  .c o  m*/
  border: 1px solid #FF0000;
  padding-left: 75px;
}
</style>
</head>
<body>

<div id="myDiv">This is a div.</div>
<br>
<button type="button" onclick="myFunction()">Change left padding</button>

<script>
function myFunction() {
  document.getElementById("myDiv").style.paddingLeft = "0px";
}
</script>

</body>
</html>



PreviousNext

Related