繁体   English   中英

将文本提交到文本框HTML中后,如何在上方显示文本

[英]How do I display text above after submitting it into a textbox HTML

我正在尝试创建一个区域,您可以在其中向文本框中输入文本,并将书面文本显示在HTML上方的框中。 我是HTML的新手,因此将不胜感激。 我画了一张我想做的美丽图画。 在此处输入图片说明

解决这种情况的最佳方法是使用Javascript或jQuery,这本身就是javascript的库。 让我向您展示如何在jQuery中进行操作

 <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script> $(document).ready(function(){ $("#form-to-be-submitted").click(function(){ $(".whatever-styling-you-want").html($("#textBox").val()); }); }); </script> <div class="whatever-styling-you-want"> </div> <!-- Your text box and submit button --> <div> <input type="text" id="textBox" placeholder="Please input your text here..."/> <input id="form-to-be-submitted" value="submit" type="button"/> </div> 

JavaScript的方式也相同。 无需使用click函数,而是将JavaScript的on函数与'click'事件一起使用。 我希望这有帮助。

<!DOCTYPE HTML>
<html>
<head>
<style>

</style>
</head>
<body>
<p id="x"></p><br>
<input id="value"><input type="button" value="submit" onClick="getV()">
<script>
function getV(){document.getElementById("x").innerHTML = document.getElementById("value").value;}
</script>
</html>

暂无
暂无

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

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