我希望延迟运行此函数 3 秒:
<script type="text/javascript">
$('#FormsPageID table tr:nth-child(12) td:nth-child(2) div span span input')
.on('focus', function(){
var $this = $(this);
if($this.val() == '4/11/2013'){
$this.val('');
}
})
.on('blur', function(){
var $this = $(this);
if($this.val() == ''){
$this.val('4/11/2013');
}
});
</script>
我遇到的所有示例都涉及使用 setTimeout 或在 X 秒后显示元素。但我不确定这将如何适用于我的职能。
最佳答案
使用设置超时:
setTimeout(function(){$('#FormsPageID table tr:nth-child(12) td:nth-child(2) div span span input')
.on('focus', function(){
var $this = $(this);
if($this.val() == '4/11/2013'){
$this.val('');
}
})
.on('blur', function(){
var $this = $(this);
if($this.val() == ''){
$this.val('4/11/2013');
}
});}, 3000);
关于javascript - 延迟运行功能 3 秒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15951708/