如何从 A 框架窗口中的表单添加文本
$("#text1").click(function(e){
var x = document.getElementById("fname").value;
//document.write(x);
document.getElementById("output").innerText = x;
return false;
});
<form name="myForm" href="" onsubmit="text" >
id: <input type="number" value="text" name="fname" id="fname"><br><br>
<input type="submit" value="Отправить">
</form>
<a-entity text="output" value="output"></a-entity>
最佳答案
使用setAttribute
更改实体上文本组件的值。
您的代码还存在一些其他问题,我已在下面修复。
$("#text1").click(function(e) {
var x = document.getElementById("fname").value;
document.getElementById("output").setAttribute("text", "value", x);
return false;
});
form {
position: absolute;
z-index: 1;
background: white;
padding: 1em;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
<form name="myForm" href="" onsubmit="text">
id: <input type="number" value="text" name="fname" id="fname"><br><br>
<input id="text1" type="submit" value="Отправить">
</form>
<a-scene background="color: black">
<a-entity id="output" text="value: output; align: center;" position="0 1.6 -0.5"></a-entity>
</a-scene>
关于javascript - 将文本从表单添加到框架窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53874955/