Home >Web Front-end >HTML Tutorial >A very simple HTML operating mechanism problem. _html/css_WEB-ITnose
html mechanism
Look at the code<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript" src="script/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#add").append("<input id='test' type='text' value=''/>"); }); function AddValue() { $("#test").val("测试值"); } </script></head><body> <form id="form1" runat="server"> <div id="add"> <input type="submit" value="测试" onclick="AddValue();"/> </div> </form></body></html>
Because the button you click is the submit button, it triggers the submission of the form, which means re-sending a request to this page (refresh the page) /post/get), you can change it to type="button", and after your function is processed, trigger submit()