使用js删除一个html按钮 [英] remove an html button using js

查看:88
本文介绍了使用js删除一个html按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我有一些代码在html表单上创建一个按钮。当用户使用按钮输入一些信息时,我希望表单通过删除按钮并用纯文本替换它来反映出来。我试图得到内部的HTML和使用div,但没有任何工作可以任何人帮助吗?我不是在寻找任何人为我写代码,只是几个指针会很棒。谢谢

Hi I have a bit of code below that creates a button on a html form. When a user has entered some information using the button I want the form to reflect this by removing the button and replacing it with just plain text. I have tried getting the inner html and using divs but nothing is working can anybody help please? I am not looking for anyone to write code for me just a few pointers would be great . thanks

  <td class="col1"><h3>Associated with :</h3></td>
  <td class="col3">
  <input type="button" 
  value="Associate this job " 
  onclick="associate()" 
/></td>


推荐答案

添加 span ,无论您想要更改哪个属性,都会包含 id 属性。现在是时候了,您需要做的就是:

Add a span with an idattribute around whatever it is you want to change. When it's time, here's all you need to do:

    document.getElementById("spanIDhere").innerHTML = "Your text here";

例如,您会有这样的行:

So for instance, you'd have the line:

    <span id="associatespan">
        <input type="button" value="Associate this job" onclick="associate()" />
    </span>

您的脚本会说:

and your script would say:

    document.getElementById("associateSpan").innerHTML = "Look, no more button!";

这篇关于使用js删除一个html按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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