I have the following code:
// JavaScript Document
$(document).ready(function(e) {
$("a.excluiAdmin").click(function() {
if (confirm('Deseja Excluir este Administrador?') ) {
var link = $(this);
$.ajax({
url: "../_requeridos/excluiAdministrador.php",
type: 'POST',
data : {
'administradorid' : $(this).attr('administradorid')
},
beforeSend: function() {
$(link).html("<img src='../_img/_bannerImgs/spinner.gif' />")
},
success: function (retorno) {
if (retorno == 1) {
alert('Excluido com sucesso');
location.reload();
} else {
alert("Erro na exclusão");
}
},
cache: false,
});
return false;
}
})
});
Within confirm
I do:
var link = $(this);
Then I get the this
of the object that undergoes the action;
And in beforeSend
I do:
beforeSend: function() {
$(link).html("<img src='../_img/_bannerImgs/spinner.gif' />")
},
So I can get the html
of the a
element that will receive the action.
I would like to know if you have something like
alert($(this).before($(this)).html())
And do not depend on doing
var link = $(this);
Is this possible?