I want to set the var index if the button is clicked. But I also want to use var index in function2. Is there a way to do this without using a global (f.e. by using return)?
HTML:
<button id="edit" onclick="editBox()">Bearbeiten</button>
JS:
function editBox() {
var index = $(event.target).parent().attr("id");
}
function function2() {
//some code...
}
function2?