Mas

Mas

  • NA
  • 473
  • 64k

How can perform click event on one image

Feb 24 2020 8:35 PM
Hello Members,
 
Here i am add the click event on one image, But we can perform click event for all the images, If we are clicking on one image, other two images we no need to get the chance of click event and how to add the tooltip on image..
  1. <li><img id="inImage" src="inempty.png" onclick="change()" height="40" width="40"/>  
  2. <img id="noImage" src="noempty.png" onclick="change1()" height="40" width="40"/>  
  3. <img id="passImage" src="passempty.png" onclick="change2()" height="40" width="40"/></li>  
  4. <script type=text/javascript>  
  5. var image = document.getElementById("inImage");  
  6. function change() {  
  7. if (image.src.match("infilled.png")) {  
  8. image.src = "inempty.png";  
  9. else {  
  10. image.src = "infilled.png";  
  11. }  
  12. }  
  13. var image1 = document.getElementById("noImage");  
  14. function change1() {  
  15. if (image1.src.match("nofilled.png")) {  
  16. image1.src = "noempty.png";  
  17. else {  
  18. image1.src = "nofilled.png";  
  19. }  
  20. }  
  21. var image2 = document.getElementById("passImage");  
  22. function change2() {  
  23. if (image2.src.match("passfilled.png")) {  
  24. image2.src = "passempty.png";  
  25. else {  
  26. image2.src = "passfilled.png";  
  27. }  
  28. }  
  29. </script>  

Answers (1)