How can I assign the id of a submit button to a variable using JQuery?
I have the following HTML:
<form id="myForm">
    <input id="oknovo" type="submit" value="OK & Novo" />
    <input id="okfechar" type="submit" value="OK & Fechar" />
</form>
JS:
var botao;
$(document).ready(function () {
    $("#myForm input[type=submit]").click(function (event) {
        botao = $(this).attr('id');
        alert("id é " + botao);
    });
});
You may see the live JSFiddle here
I've already managed to indentify the clicked button wiht the help of this question but the problem now is to assign it to a global variable.
 
     
     
     
    