I have a simple question. My JS code is like this, but when I try to add a new element or content to the <div>, it comes up then goes up quickly. I don't know why.
How can I avoid this?
<head> $(document).ready(function () { $('#mybtn').click(function () { $('#main').append('<button id ="mm" onclick="myfun()">generate code my fun.</button>'); }); }); </head> <body> <form id="form1" runat="server"> <button id ="mybtn">generate code</button> <div id="main"></div> </form> </body>
type, example :<button type="button" id="mybtn">generate code</button>. This will stop the button from Submitting.<form>tag? (If its .ASPX then I guess it would be.) If so then try my suggestion of setting thetypeof the button.