A very simple HTML operating mechanism problem. _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:25:17
Original
1007 people have browsed it

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>
Copy after login

Why click the test button. After setting the value of the text box, it disappears immediately. If you add return false; after onclick.
Will the page refresh when you click on the input control?

Reply to discussion (solution)

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()

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template