How to use JavaScript DOM to change the padding of a table?

JavascriptObject Oriented ProgrammingFront End Technology

To change the padding of a table, use the DOM padding property. You can try to run the following code to change the padding in JavaScript −


<!DOCTYPE html>
         function paddingFunc(x) {
            document.getElementById(x).style.padding = "20px";
      <table style = "border:2px dashed black" id = "newtable">

         <input type = "button" onclick = "paddingFunc('newtable')" value = "Change Table Padding">
Updated on 23-Jun-2020 10:59:21