Difference between Jquery Html callback function and append function? -


what difference between jquery html callback function (source http://www.w3schools.com/jquery/jquery_dom_set.asp) , jquery append function (source http://www.w3schools.com/jquery/jquery_dom_add.asp)

also ecsctly use of parameter index in jquery html callback function?

callback used manipulate content of html element. here can put logic handle text provided , return modified text.

in below code, adding original text new 1 return index. same way can put own logic handle text.

$("#test1").text(function(i, origtext){     return "old text: " + origtext + " new text: hello world!      (index: " + + ")";  }); 

while in append got choice add more text after existing text , nothing can done extra.

in below example, appending new text existing text.

$("p").append("some appended text."); 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -