I'm trying to access the value of a variable that is set inside a .click
function outside of the function but I'll get the error, can anyone please tell me what I'm doing wrong?
var id;
var currentPosition;
var slideWidth = 368;
var slides;
var numberOfSlides;
$('#accordion_catering h3').click(function() {
id = $(this).attr('id');
$('#' +id+'_gallery').show();
//alert(id);//works
});
alert(id); // is undefined
// Because id is undefined these don't work .
slides = $('.' + id + '_slide');
numberOfSlides = slides.length;