Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ESERCIZIO 4
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <p>Sono un paragrafo</p>
- <button>Bottone</button>
- <a href="www.camuso.it"> Vai al sito del prof.</a>
- <b>Importante!</b>
- <img src="img/imm1.JPG">
- <script>
- window.addEventListener("click", function() {
- if(document.body.lastElementChild.previousElementSibling!==null)
- document.body.lastElementChild.previousElementSibling.remove();
- });
- </script>
- </body>
- </html>
- //ESERCIZIO 5
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <p>Sono un paragrafo</p>
- <button>Bottone</button>
- <a href="www.camuso.it"> Vai al sito del prof.</a>
- <b>Importante!</b>
- <img src="img/imm1.JPG">
- <script>
- //array con i riferimenti di tutti gli elementi figli del body
- let figli_del_body = document.querySelectorAll("body>*");
- //escludiamo questo stesso script
- for (let i=0; i<figli_del_body.length - 1; i++)
- figli_del_body[i].addEventListener("click", function (e) {
- e.preventDefault();
- this.remove();
- })
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement