简体   繁体   English

Javascript将输出添加到div

[英]Javascript to add output to div

Alright, I have some javascript that pull the input from a form input (no submit button is used). 好的,我有一些JavaScript可从表单输入中提取输入(不使用提交按钮)。

<script type="text/javascript">
$("input#level").keyup(function () {
  var value = $(this).val();
  $("span#level-text").text(value);
}).keyup();

This then adds the content into a span clan. 然后,将内容添加到跨度氏族。 I would love to take this input and then add it to another div (#test). 我希望接受此输入,然后将其添加到另一个div(#test)。 I guess I basically need to take two numbers (two different inputs), and add them together and have the new added number out put to another div (all without a submit) 我想我基本上需要取两个数字(两个不同的输入),并将它们加在一起,然后将新添加的数字放入另一个div中(所有这些都无需提交)

Assuming you are asking to take two inputs place each those values in a span and also add their values together in another div. 假设您要接受两个输入,则将这些值分别放在一个跨度中,并将它们的值一起添加到另一个div中。 You would do something like this: JSFiddle Example 您将执行以下操作: JSFiddle示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM