I have several HTML elements that I want to execute the same function, in different mouseover, click, etc. events.
I did not want to repeat the same code for each of the elements. Example: here I apply in the change event of a select, but I want to apply for the mouseover event of a button, and the click of a link, that will do all this same. Do I have to copy all the code again? I do not have how to call this same code without having it repeated.
$('select[name=confirm]').change(function() {
entradav = $('input[name=fechaent]').val();
salidav = $('input[name=fechasal]').val();
quartov = $('select[name=quartos]').val();
idv = $('input[name=id]').val();
$("#modal-footer").delay(1000).queue(function(n) {
$("#modal-footer").html('<img src="./img/ajax-loader_blue.gif" />');
$.ajax({
type: "POST",
url: "compruevaover.php",
data: 'entrada=' + entradav + '&salida=' + salidav + '&quarto=' + quartov + '&id=' + idv,
dataType: "html",
error: function(){
alert("error petición ajax");
},
success: function(data){
$("#modal-footer").html(data);
n();
}
});
});