请问一下这个代码我加一个"变化"按钮,然后在函数中怎么写代码能实现将文本框里输入的内容字体改变大小,改变颜色之后输出?
<head>
<script>
function change()
{
alert(fm1.a.value);
}</script>
</head>
<body>
<form id="fm1">
<input  id="a" type ="text" name="text1">
<input type="button" value="显示" onclick="change()">
</form>
</body>
我是个初学者 谢谢啦~

解决方案 »

  1.   

    <div id='out'></div>
    function print()
    {
    var t=document.createTextNode(document.getElementById('a').value);
    document.getElementById('out').appendChild(t);
    }
      

  2.   

    function print()
    {
    var tt=document.createElement('font');
    tt.setAttribute('color','blue');
    var t=document.createTextNode(document.getElementById('a').value);
    tt.appendChild(t);
    document.getElementById('out').appendChild(tt);
    }
    <div id='out'> </div>
    这样可以改变颜色
      

  3.   


    <script> 
    function change1() { 
    var obj=document.getElementById("a")
    if (obj.value.length>0){obj.style.fontSize="20px";obj.style.color="#f00"}
    }
     
    function change2() { 
    var obj=document.getElementById("a")
    if (obj.value.length>0){
    var newTag=document.createElement("div")
    with(newTag.style){
    fontSize="50px"
    fontWeight="700"
    color="0aa"
    border="1px red solid"
    position="absolute"
    top="200px"
    left="280px"
    padding="20px"
    }
    newTag.innerHTML=obj.value
    document.body.appendChild(newTag)
    }
    } </script> 
    </head> 
    <body> 
    <form id="fm1"> 
    <input  id="a" type ="text" name="text1"> 
    <input type="button" value="显示1" onclick="change1()"> 
    <input type="button" value="显示2" onclick="change2()"> 
    </form> 
    </body>