Я пытаюсь использовать bootbox с Twitter Bootsrap.
В приведенном ниже коде, когда я использую this.attr('href');
, и получаю TypeError: this.attr is not a function
.
Когда я перехожу на $(this).attr('href');
, я получаю Undefined
.
<a class="alert" href="list_users.php?id=123">Delete user</a>
<script src="bootbox.min.js"></script>
<script>
$(document).on("click", ".alert", function(e) {
e.preventDefault();
bootbox.confirm("Are you sure?", function(result) {
if (result) {
document.location.href = this.attr('href'); // doesn't work
document.location.href = $(this).attr('href'); // Undefined
}
});
});
</script>
Есть идеи?
jQuery! == Javascript – PlantTheIdea