I am currently facing an issue where I am unable to retrieve a variable from a JavaScript function and use it outside of the function. While I can successfully output the variable value inside the function, I am struggling to access it elsewhere in my script. Here is the code snippet, but I need help figuring out how to extract the value of 'status' and utilize it outside of the function:
<script>
function get_id(){
$('.addressClick').click(function() {
var status = $(this).attr('id');
alert(status); // The correct value is displayed here
return status;
});
}
var variable = get_id();
alert(variable); // The variable isn't displaying here
$("#"+variable).confirm();
</script>