<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> JavaScript dynamically create input text box </title>
<style type= "Text/css" >
<!--
Body {
font:12px "Microsoft Sans Serif";
}
. textstyle{
width:300px;
height:16px;
line-height:16px;
border:1px solid #006699;
font:12px "Microsoft Sans Serif";
padding:2px;
Color: #006699;
}
-->
</style>
<script type= "Text/javascript" >
Copyright 2008
By Xiao Wu classmate qq:100052800
Date 2008-11-25
Create an input text box
function Createinput () {
var input = document.createelement ("input");
Input.type = "text";
Input.id = "Inputtext";
Input.value = "This text box is JS created";
If you use CSS to define the input style, you can use ClassName to specify the style name, such as using JS to create, and let go of the comments below
Input.classname = "TextStyle";
Use the following definitions to annotate//input.classname = "TextStyle";
/*input.style.width = "300px";
Input.style.height = "16px";
Input.style.lineHeight = "16px";
Input.style.border = "1px solid #006699";
Input.style.font = "12px ' Microsoft Sans Serif '";
input.style.padding = "2px";
Input.style.color = "#006699";
document.getElementById ("Showtext"). appendchild (input);
}
</script>
<body onload= "Createinput ()" >
<div id= "Showtext" ></div>
<input type= button "onclick=" Alert (document.getElementById (' Inputtext '). Value) "value=" gets the value to create the text box/>
</body>