I have one function, but two events. First event for input and keypress, second event for button and click.
<input class="text">
<button class="btn">Next</button>
And jquery code:
function submit() {
var inputValue = $( '.text' ).val();
alert('inputValue');
};
$('.btn').on('click', function () {
submit();
});
$('input').keydown(function(e) {
if(e.which == 13) {
submit();
}
});
Can I join these two events?