当我单击添加按钮时,不想创建新的文本字段 [英] when i click add button,t want to create new text field

查看:63
本文介绍了当我单击添加按钮时,不想创建新的文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击添加"按钮时,不想创建新的文本字段.

when i click add button,t want to create new text field.

推荐答案

我单击添加"按钮想创建新的文本字段.
i click add button want to create new text field.
Javascript

1. Define client side button click event
2. In the button click event, create an input element
3. define the properties like id, width, type etc of the input element
4. Add the input element to a defined div/placeholder

A new text field will be created and shown in the given location. Try!


查看此脚本
动态文本框
see this script
Dynamically textbox


尝试一下,


Try this,


<div id="div2"></div> 

<input type="button" id="btnok" onclick="addText();" value="text" />
        <br /> 





<script type="text/javascript">
function addText()
        {
        var div1=document.getElementById("div2");
        div1.innerHTML="<input type='text'/>";
        }
 </script>


这篇关于当我单击添加按钮时,不想创建新的文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆