index.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. let picture = 'https://lh3.googleusercontent.com/proxy/1dtMIJmaPfoqtMW2W7m_KVaTmE-_nC9-wFdgF26ZBLSBA0vhRYsNfIzJt9AGRC4l_nCuT3995s6A1A_I0J_SjlSsh0TMqfpkKULrAHjC-0leO_2qozYtf2ubPrsTAsunOgAHYprx278PbuNlSLHZyOLD'
  2. let p = document.body.appendChild (document.createElement('p'));
  3. p.style = `
  4. width: 220px;
  5. color: purple;
  6. font-size: 22px;
  7. cursor: pointer;`
  8. p.innerText = `There will be a cat. Click ME!`
  9. p.onclick = function(event) {
  10. let img = event.target.appendChild (
  11. document.createElement ('img')
  12. )
  13. img.src = picture;
  14. img.id = 'photo';
  15. img.width = 100;
  16. img.style.margin = 50;
  17. img.onmouseover = function(event) {
  18. let imgBig = document.getElementById('photo');
  19. imgBig.width = 200;
  20. imgBig.style.transitionDuration = '.8s'
  21. }
  22. img.onmouseout = function(event) {
  23. let imgBig = document.getElementById('photo');
  24. imgBig.width = 100;
  25. imgBig.style.transitionDuration = '.8s';
  26. }
  27. img.addEventListener( 'click', function(event) {
  28. let imgBig = document.getElementById('photo');
  29. imgBig.remove();
  30. })
  31. }