문제점이 있습니다 ... 어떻게이 두 텍스트 필드에 개별적으로 넣은 것을 표시 할 수 있습니까?자바 스크립트, 되풀이 루프
<input type="text" id="userInput"></input> <button id="submitter">Submit</button>
<div id="output" style="white-space: pre-wrap; display: inline;"></div>
<input type="text" id="userInput"></input> <button id="submitter">Submit</button>
<div id="output" style="white-space: pre-wrap; display: inline;"></div>
<script type="text/javascript">
var didClickIt = false;
document.getElementById("submitter").addEventListener("click",function(){
// same as onclick, keeps the JS and HTML separate
didClickIt = true;
});
setInterval(function(){
// this is the closest you get to an infinite loop in JavaScript
if(didClickIt) {
didClickIt = false;
// document.write causes silly problems, do this instead (or better yet, use a library like jQuery to do this stuff for you)
var o=document.getElementById("output"),v=document.getElementById("userInput").value;
if(o.textContent!==undefined){
o.textContent=v;
}else{
o.innerText=v;
}
}
},500);
</script>
내 문제는 값이 입력 될 때 상자 중 하나가 일을 해달라고입니다. 이 문제를 어떻게 해결할 수 있습니까?
왜 아래 표를 보냅니 까? – Fabio