html
<p>This is a <b>bold</b> paragraph.</p>
<button>Add</button>
jquery
$("button").click(function(){
$("p").text(function(i,origText){
return "Old text: " + origText + " New text: Hello world! (index: " + i + ")";
});
});
I would like to know origText is not called outside function but it is returning the value. How?