Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Дан инпут. Пусть в него вводится число. По потери фокуса выведите на экран квадрат этого числа.
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Тег IMG</title>
- </head>
- <body>
- <input id="elem" value="text">
- <div class="result"></div>
- <script>
- let elem = document.querySelector('#elem');
- elem.addEventListener('focus', function() {
- // console.log(elem.value);
- let input = document.getElementById('elem').value;
- document.getElementById('elem').value = input**2;
- });
- </script>
- </body>
- </html>
- правильно?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement