You need to define the button text and have valid HTML for the button. I would also suggest using .on for a button click handler
$(function () { $('#Add').on('click', function () { $('<p>Text</p>').appendTo('#Content'); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="Content"> <button id="Add">Add Text</button> </div>
I would also like to make sure that jquery is at the bottom of the page before the closing </body> . This will make it so that you donβt need to have the whole thing wrapped in $(function , but I will do it anyway. If your javascript loading at the end of the page makes it so that the rest of the page loads, there is somewhere slower in your javascript.
bretterer Mar 22 '13 at 22:51 2013-03-22 22:51
source share