turn every image with a specific class into a hyperlink - Javascript jQuery

Javascript examples for jQuery:Image

Description

turn every image with a specific class into a hyperlink

Demo Code

ResultView the demo in separate window

<!doctype html>
<html lang="en">
 <head> 
  <title>on demo</title> 
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script> 
 </head> //ww  w. j a v a2  s .c  o  m
 <body> 
  <img class="question-image" alt="" src="http://www.java2s.com/style/demo/InternetExplorer.png"> 
  <script>
        $(".question-image").click(function () {
            window.open('http://java2s.com/', '_blank');
        });
    
      </script>  
 </body>
</html>

Related Tutorials