BootBox JS for Twitter Bootstrap - how to pass data into the callback function? <p>JS/JQuery newbie here. I'm using BootBox for Twitter Bootstrap, and I'm trying to pass the value of the id attribute of an a element into the callback function:</p> <pre><code>&lt;a class="confirmdel" id="&lt;?= $folioid ?&gt;" href="#"&gt; Delete&lt;/a&gt; &lt;script&gt; $(document).on("click", ".confirmdel", function(e) { var folioid = ($(this).attr('id')); bootbox.dialog("Do you really want to delete this folio entry?", [{ "label" : "Yes", "class" : "btn-danger", "icon" : "icon-trash", "callback": function() { window.location.replace("deletefolio.php?folioid="+$folioid); } }, { "label" : "No", "class" : "btn", }]); }); &lt;/script&gt; </code></pre> <p>It seems i can't use $(this) inside the callback function because in there it doesn't refer to the a element but to the window instead, and I have no idea how to pass the variable into the callback from outside.</p> <p>Maybe I'm thinking about it the wrong way entirely.</p> <p>Any suggestions greatly appreciated!</p>