//add text after the last child $("#btn1").click(function () { $("#showBlock").append('hello'); }); //add text before the last child $("#btn2").click(function () { $("#showBlock").prepend('hello'); });
<body> <!-- add new item Dynamically in the show block --> <div id="showBlock"> Input:<input type="text" name="test[]" /> </div> <!-- click the button to add new item --> <input type="button" id="btn1" value="addtextLast"/> <input type="button" id="btn2" value="addtextPre"/> </body>