Advertisement
lemansky

Untitled

Mar 31st, 2021
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.54 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Document</title>
  6.     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
  8.     <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
  9.     <script>
  10.         document.addEventListener('DOMContentLoaded', function(event){
  11.             // clean(document.body);
  12.             let _btn = document.getElementsByClassName('btn')[0];
  13.             _btn.addEventListener('click', () => {
  14.                 let input = document.getElementById('a1');
  15.                 // let styles = window.getComputedStyle(input);
  16.                 // let padding = styles.getPropertyValue('padding');
  17.                 // let pVertical = padding.split(' ')[0].split('px')[0];
  18.                 // let pHorizontal = padding.split(' ')[1].split('px')[0];
  19.                 // input.style.padding = (parseInt(pVertical) + parseInt(input.value)) + 'px ' + (parseInt(pHorizontal) + parseInt(input.value)) + 'px';
  20.  
  21.                 // let p = input.style.padding;
  22.                 // if(p.length > 1) {
  23.                 //     p = parseInt(p);
  24.                 //     input.setAttribute('style', 'padding:' + (parseInt(input.value) + p) + 'px');
  25.                 // } else {
  26.                 //     input.setAttribute('style', 'padding:' + (input.value) + 'px');
  27.                 // }
  28.                
  29.             });
  30.  
  31.         });
  32.         const clean = (node) =>
  33.         {
  34.           for(var n = 0; n < node.childNodes.length; n ++)
  35.          {
  36.            var child = node.childNodes[n];
  37.            if
  38.            (
  39.              child.nodeType === 8
  40.              ||
  41.              (child.nodeType === 3 && !/\S/.test(child.nodeValue))
  42.            )
  43.            {
  44.              node.removeChild(child);
  45.              n --;
  46.            }
  47.            else if(child.nodeType === 1)
  48.            {
  49.              clean(child);
  50.            }
  51.          }
  52.        }
  53.     </script>
  54. </head>
  55. <body>
  56.     <div class="container">
  57.         <div class="row">
  58.             <div class="form-group form-inline m-3">
  59.               <label for="a1">Добави още Падинг</label>
  60.               <input type="text" class="form-control mx-3" id="a1" placeholder="Падинг">
  61.               <button type="button" class="btn btn-primary">Добави</button>
  62.             </div>
  63.         </div>
  64.     </div>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement