中易网

html代码问题,页面有一个按钮和一个文本框,我想点击按钮后文本框就=“点击了”。请问代码要怎么写?谢

答案:2  悬赏:60  
解决时间 2021-04-28 22:48
  • 提问者网友:熱戀丶瘋
  • 2021-04-28 00:01
基础代码如下,请修改:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<label for="001">textbox1</label>
<input type="text" name="001" id="001" />
button1
<input type="button" name="002" id="002" value="提交" />
</form>

</body>
</html>
最佳答案
  • 二级知识专家网友:专属的偏见
  • 2021-04-28 01:06
<input type="button" name="002" id="002" value="提交" onclick="this.value='点击了'" />
全部回答
  • 1楼网友:迷人小乖乖
  • 2021-04-28 02:37
一: <html> <body> <div id="txtre" style="height:20px;"></div> <input type=text id="txtuser" onkeyup="javascript:document.getelementbyid(&apos;txtre&apos;).innerhtml=this.value;"> </body> </html> 二: <html> <head> <script> function checkword(tobj,dobj){ var val=document.getelementbyid(&apos;txtre&apos;).innerhtml; var wor=tobj.value; wor=wor.replace(/(^\s*)|(\s*&#36;)/g,""); var newval=""; for(var ii=0;ii<val.length;ii++){ var oneword=val.substring(ii,ii+1); if(ii<wor.length){ if(oneword==wor.substring(ii,ii+1)){ newval+="<font color=&apos;green&apos;>"+wor.substring(ii,ii+1)+"</font>"; }else{ newval+="<font color=&apos;red&apos;>"+wor.substring(ii,ii+1)+"</font>"; } } } dobj.innerhtml=newval; } <&#47;script> </head> <body> <div id="txtre" style="height:20px;">hello!my name is lc.</div> <div id="txtsr" style="height:20px;"></div> <input type=text id="txtuser" onkeyup="checkword(this,document.getelementbyid(&apos;txtsr&apos;))"> </body> </html>
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息