Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <div>
- <p data-message="hello">Hello, World</p>
- <ul>
- <li></li>
- </ul>
- <p>Try again</p>
- </div>
- </body>
- </html>
- var el = document.querySelector('li');
- el.closest('p[data-message]');
- el.closest('div').querySelector('p[data-message]')
Add Comment
Please, Sign In to add comment