Guest User

Untitled

a guest
Feb 9th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <style type="text/css">
  6. .container{
  7. border: 1px solid #999;
  8. }
  9. label{
  10. display: block;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15.  
  16. <div class="container">
  17. <label>username:</label><input type="text" name="">
  18. <label>pass: <input type="password" name=""></label>
  19. </div>
  20. <button class="btn">Click</button>
  21. <div class="output"></div>
  22.  
  23.  
  24. <script type="text/javascript">
  25. let container = document.querySelector('.container');
  26.  
  27. function clickInputHandler(e){
  28. let el = e.target;
  29.  
  30. console.log(el.tagName);
  31.  
  32. if (el.tagName == "INPUT"){
  33. el.style.background = "red";
  34. }
  35. }
  36.  
  37. container.addEventListener('click', clickInputHandler )
  38.  
  39. </script>
  40. </body>
  41. </html>
Add Comment
Please, Sign In to add comment