How to access JavaScript variable from one function to another. : How to access JavaScript variable from one location click event function to another. 

I have a variable `imdid `, I wan to access this variable in my different click event, How Can i do that. 



    $( document ).ready(function() {
    
    
    	$(".img-upload").click(function(){
    		
    		//$("#modal").modal('show');
    		
    		var imdid = $(this).attr("imgid");
    		
    	
    		
    	});
    	
    	
    	$(".img-gallary").click(function(){
    		
    		var imgsrc = $(this).attr("src");
    		
    		alert(imgsrc);
    		
    		alert(imdid);
    		
    	});	
    
    	
    });
    	
    });


Many Thanks
	 