I am trying to get a variable from a javascript function, but I am having a problem getting it the variable value outside the function. The variable value can be outputted just fine inside the function. Here is the script, but how can I get the value of status and use it outside the funcion? Maybe I am doing it in the wrong way, but in the end I want the value of variable to be the value of status.
<script>
function get_id(){
$('.addressClick').click(function() {
var status = $(this).attr('id');
alert(status); // Here the value is printed correctly
return status;
});
}
var variable = get_id();
alert(variable); // Here the valiable isn't outputed
$("#"+variable).confirm();
</script>