我想在聚焦时使占位符文本闪烁。
这是我的 html 代码:
<input type="text" id="keyfob" class="customform col-sm-12 text-red" data-required='true' placeholder=" Please click here to Key Fob scanning work">
这是我的 jquery 代码:
$('#keyfob').on("focus blur", function(){
$(this).attr("placeholder") == "" ? $(this).attr("placeholder", "Please click here for Key Fob scanning to work") : $(this).attr("placeholder", "");
});
现在我想闪烁占位符文本“请单击此处进行 key 卡扫描工作”。
所以请有人能帮帮我吗???
最佳答案
这里是jquery
function blink() {
if ($('input[type=text]').attr('placeholder')) {
// get the placeholder text
$('input[type=text]').attr('placeholder', '');
}
else {
$('input[type=text]').attr('placeholder', 'Placeholder Text...');
}
setTimeout(blink, 1000);
}
html
<body onload='blink()'>
<input type="text" on-click='blink()' id="keyfob" class="customform col-sm-12 text-red" data-required='true' placeholder=" Please click here to Key Fob scanning work">
关于javascript - 如何在输入文本字段中使占位符闪烁到 focusout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28472901/