版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/suyimin2010/article/details/85912592
1.布局
<input id="timeInput" class="timeInput" placeholder="设置秒数" size="7" maxlength="10" onkeyup="this.value=this.value.replace(/\D/g,'')"/>
样式
.process-text input{
position: relative;
background: transparent;
height: 100%;
font: bold;
outline:none;
z-index: 10;
}
.process-text input:read-only {
border: 2px solid cadetblue;
}
逻辑
$(".timeInput").on("focus", function(){
$(this).attr("readonly", "readonly");
});
$(".timeInput").on("blur", function(){
$(this).css("border", "").removeAttr("readonly");
});
$(".timeInput").keydown(function(event){
$this = $(this);
if(event.which == "13") {
if("" === $(this).val())
{
return;
}
$(".video")[0].currentTime = $(this).val();
$video.play();
$(this).val("");
}
if(57 >= event.keyCode && 48 <= event.keyCode)
{
$this.val($this.val() + (event.keyCode-48).toString());
}
});