Having two simple htmls, on click of any href in first html, redirect to second html and do something on all obj of class 'clazz':
first html:
<body>
<a class="link" id="1" href="display.html" >flower 1</a>
<a class="link" id="2" href="display.html" >flower 2</a>
<script src="http://code.jquery.com/jquery-latest.min.js"
    type="text/javascript"></script>
<script src="js/script.js"></script>
</body>
second:
  <body> 
  <img class ="clazz" id="1" src="https://">
  <img class ="clazz" id="2" src="https://">
  <script src="http://code.jquery.com/jquery-latest.min.js"
        type="text/javascript"></script>
  <script src="js/script.js"></script>
</body>
js:
 $(document).ready(function() {
    $('.link').on('click', function( event ) 
     {
         $(".clazz").each(function() {
           alert("hey");
         });
     });
 });
Although the code is simple, something weird happens.. The .each on clazz is never invoked. When moving the .each section out of link.onClick - it shows the alerts so I assume the problem is not unrecognized class 'clazz' of the second html in the js. What else could it be?
 
     
     
     
    