Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var current_object;
  2. var selected_object;
  3.  
  4. var onClick= function(){
  5.    
  6.     selected_object = $(this).attr('src');
  7.  
  8.    if(selected_object != 'NULL' && current_object == 'NULL' || current_object == undefined){
  9.      
  10.         current_object = selected_object;
  11.         selected_object = 'NULL';
  12.      
  13.     }
  14.    
  15.   else if(selected_object != 'NULL' && current_object != 'NULL' ){
  16.        
  17.       if (selected_object == current_object)
  18.       {
  19.        
  20.         $('img').each(function(){
  21.        
  22.             if($(this).attr('src') ==  selected_object){
  23.                
  24.                 $(this).remove();
  25.             }
  26.         });
  27.  
  28.        
  29.             if (!$('img').is(":visible")) {
  30.                 alert("Du klarade det!");
  31.                 selected_object= 'NULL';
  32.                 current_object= 'NULL';
  33.             }
  34.            
  35.             else {
  36.                 selected_object= 'NULL';
  37.                 current_object= 'NULL';
  38.             }
  39.        
  40.       }
  41.      
  42.       else{
  43.      
  44.           alert ("NO! Fel!");
  45.           selected_object= 'NULL';
  46.           current_object= 'NULL';
  47.      
  48.       }
  49.     }
  50.  
  51.    
  52.  };
  53.  
  54.  $('img').click(onClick);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement