日期:2014-05-16  浏览次数:20483 次

新手学习,请老师们帮忙~感谢感谢!
做了一组Div的按钮,每个按钮的值是一个数字,从1到15。
我用javascript控制它的默认样式和被选中的样式,点击改变样式的同时把值赋给type=text的input。
请教老师们,如果我从选种状态点回默认状态的时候怎么才能把input中的对应值也清除呢?多谢了!
代码如下:
[code]
function   ShowNmbr(DiValue)
    {
        var   ShowDNmbr   =   'DNmbr '   +   DiValue;
        if(document.getElementById(ShowDNmbr).className   ==   "YelNmbr ")
            {
            document.getElementById(ShowDNmbr).className   =   "RedNmbr "
            document.getElementById( "UrLtryNumber ").value+=   DiValue   +   "   "
            }
        else   if(document.getElementById(ShowDNmbr).className   ==   "RedNmbr ")
            {
            document.getElementById(ShowDNmbr).className   =   "YelNmbr "
            }
}
[/code]
div是下面这样作的
[code]
<div   id= "LtryNmbrBox ">
    <div   class= "LtryNmbrRow1 ">
        <div   class= "YelNmbr "   id= "DNmbr1 "   onclick= "Javascript:ShowNmbr(1); "> <span> 1 </span> </div>
        <div   class= "YelNmbr "   id= "DNmbr2 "   onclick= "Javascript:ShowNmbr(2); "> <span> 2 </span> </div>
        <div   class= "YelNmbr "   id= "DNmbr3 "   onclick= "Javascript:ShowNmbr(3); "> <span> 3 </span> </div>
        <div   class= "YelNmbr "   id= "DNmbr4 "   onclick= "Javascript:ShowNmbr(4); "> <span> 4 </span> </div>
        <div   class= "YelNmbr "   id= "DNmbr5 "   onclick= "Javascript:ShowNmbr(5); "> <span> 5 </span> </div>
    </div>
    <div   class= "LtryNmbrRow2 ">
        <div   class= "YelNmbr "   id= "DNmbr6 "   onclick= "Javascript:ShowNmbr(6); "> <span> 6 </span> </div>
        <div   class= "YelNmbr "   id= "DNmbr7 "   onclick= "Javascript:ShowNmbr(7); "> <span> 7 </span> </div>
        <div   class= "YelNmbr "   id= "DNmbr8 "   onclick= "Javascript:ShowNmbr(8); "> <span> 8 </span> </div>
        <div   class= "YelNmbr "   id= "DNmbr9 "   onclick= "Javascript:ShowNmbr(9); "> <span> 9 </span> </div>
        <div   class= "YelNmbr "   id= "DNmbr10 "   onclick= "Javascript:ShowNmbr(10); "> <span> 10 </span> </div>
    </div>
    <div   class= "LtryNmbrRow3 ">
        <div   class= "YelNmbr "   id=