[英]On div refresh text inside the input box shouldn't clear
我有一个div,它每3秒刷新一次。 在该div内有一个输入框,我输入的任何内容都会在3秒钟内清除。 有没有办法让文本保留在输入框中而不被清除?
index.js
<div id="show_here"></div>
<script type ="text/javascript">
$(document).ready(function() {
setInterval(function() {
$('#show_here').load('fetch.php')
}, 3000);
});
</script>
fetch.php
<div>
// some code here
<input type="text" id="input" />
</div>
输入框必须位于该页面内,因为它位于while循环内。 可以做到这一点,还是我需要更改整个代码才能完成此工作?
保留然后设置
setInterval(function() {
my_val = $('#input').val();
$('#show_here').load('fetch.php');
$('#input').val(my_val);
}, 3000);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.