SHARE
TWEET

Untitled

a guest May 22nd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <meta name="viewport" content="width=device-width">
  6.   <title>JS Bin</title>
  7. </head>
  8. <body>
  9. <p>
  10. Piłka nożna
  11. </p>
  12. <p>
  13. Siatkówka
  14. </p>
  15. <p>
  16. Narciarstwo
  17. </p>
  18.  
  19.   <script>
  20.     const pArray = document.querySelectorAll('p');
  21.     pArray.forEach((p, index) => {
  22.       if(index !== 0) {
  23.         pArray[index].addEventListener('click', () => {
  24.           console.log(pArray[index].textContent)
  25.           const tempP = pArray[0].textContent;
  26.           pArray[0].textContent = pArray[index].textContent
  27.           pArray[index].textContent = tempP
  28.         })
  29.       }
  30.     })
  31.   </script>
  32. </body>
  33. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top