【问题标题】:Click the button and it sends that info into another box on the page [closed]单击该按钮,它将该信息发送到页面上的另一个框中[关闭]
【发布时间】:2019-02-24 15:16:43
【问题描述】:

我希望能够单击一个按钮,然后将该信息放入页面的另一部分(在一个框中)。但是,我也希望能够从该框中删除它。

使用 html 和 javascript 执行此操作的最佳方法是什么?

谢谢

【问题讨论】:

  • 你试过什么?任何html、css或js代码?
  • 请明确您的意思:that information, into another part of the page, remove this from that box

标签: javascript html css button


【解决方案1】:

使用html、css 和jQuery,您可以获得所需的输出。 请检查以下代码。

function getHtml() {
  var test = $("#input").text();
  $("#output").show();
  $("#remove").show();
  $("#output").text(test);

}

function remove() {
  $("#output").hide();
  $("#remove").hide();

}
#output {
  display: none;
}

#remove {
  display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="input">
  Input: welcome
</div>
<button onClick="getHtml()">Click</button>
<div id="output">
</div>
<button id="remove" onClick="remove()">Remove</button>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-08
    • 2013-02-07
    • 1970-01-01
    • 2012-09-21
    • 1970-01-01
    • 2021-07-15
    相关资源
    最近更新 更多