Home > Web Front-end > JS Tutorial > js simple method to dynamically increase the number of input boxes by clicking a button in a form_javascript skills

js simple method to dynamically increase the number of input boxes by clicking a button in a form_javascript skills

WBOY
Release: 2016-05-16 15:44:30
Original
2041 people have browsed it

The example in this article describes how to simply implement js to dynamically increase the number of input boxes by clicking a button in a form. Share it with everyone for your reference. The details are as follows:

Here is a demonstration of how to dynamically increase the number of input boxes by clicking a button in a form. The default is that there is no input box. After clicking the button, the input boxes will continue to increase. Each time you click, one will be added. I think it is pretty good. I hope it will be helpful to you. helped.

The operation effect is as shown below:

The online demo address is as follows:

http://demo.jb51.net/js/2015/js-table-input-button-add-codes/

The specific code is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>点击按钮动态增加输入框数量</title>
</head>
<body>
<script>var i=1</script>
<input type=button onclick="document.body.insertAdjacentHTML('beforeEnd','<input type=text name='+i+' value='+i+++'> ')" value=添加>
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
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