Prepend: adds text at the beginning. Append: adds text at the end. <!DOCTYPE html > < html > < head > < script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" ></ script > < script > $ ( document ). ready ( function (){ $ ( "#btn1" ).click( function (){ $ ( "p" ). prepend ( "<b>Prepended text</b>. " ); }); $ ( "#btn2" ).click( function (){ $ ( "div" ). append ( "<b>Appended text</b>" ); }); }); </ script > </ head > < body > < p > This is a paragraph. </ p > < div > This is another paragraph. </ div > < button id= "btn1" > Prepend Text </ button > < button id= "btn2" > Append Text </ button > </ body > </ html ...
Code at your best..!