2015-09-15 8 views

ответ

1

кэш контекст с this:

$('#something li').click(function(){ 
    var $this = this; // cache it here 
    bootbox.confirm("Are you sure?", function(result) { 
     if(result == true){ 
      alert("You deleted" + $this.textContent/*use it here now!!*/); 
     } 
    }); 
}); 
+0

Именно то, что я искал. спасибо –

0

В этом контексте вы можете использовать $(this).

$('#something li').click(function(){ 
    console.log($(this)); 
}); 

См: https://api.jquery.com/click/

+0

Я хочу использовать его внутри функции bootbox.confirm и $ (это) получает контекст функции подтверждающим –

+0

О, я вижу, что ответ Джей будет для вас идеальным. – DDan