Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <style type="text/css">
- .container{
- border: 1px solid #999;
- }
- label{
- display: block;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <label>username:</label><input type="text" name="">
- <label>pass: <input type="password" name=""></label>
- </div>
- <button class="btn">Click</button>
- <div class="output"></div>
- <script type="text/javascript">
- let container = document.querySelector('.container');
- function clickInputHandler(e){
- let el = e.target;
- console.log(el.tagName);
- if (el.tagName == "INPUT"){
- el.style.background = "red";
- }
- }
- container.addEventListener('click', clickInputHandler )
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment