[英]Hide placeholder test onfocus on firefox browser
I use HTML5 placeholder attribute to label form elements. 我使用HTML5占位符属性标记表单元素。
I wish to hide the placeholder onfocus event, But in firefox it dissappears only when user starts to type. 我希望隐藏占位符onfocus事件,但是在Firefox中,它仅在用户开始键入时才消失。
It goes well with on all other web browsers when i use the following style 当我使用以下样式时,它在所有其他Web浏览器上都可以正常运行
[placeholder]:focus::-webkit-input-placeholder {
color: transparent;
}
but not on latest version of firefox. 但不是最新版本的firefox。
How to hide placeholder onfocus on firefox browser? 如何在Firefox浏览器上隐藏占位符?
You're having jQuery option too. 您也有jQuery选项。 Try this:
尝试这个:
var placeholderValue = "";
$('input').focus(function () {
placeholderValue = $(this).attr('placeholder'); // save the value
$(this).attr('placeholder', ''); // remove the value for that
}
$('input').blur(function () {
$(this).attr('placeholder', placeholderValue); // update the value! :)
}
And do the counter for this, when there is a blur event, give it back its value! 并为此做计数器,当发生模糊事件时,将其值还给它!
Updated fiddle: http://jsfiddle.net/afzaal_ahmad_zeeshan/nHYhK/1/ 更新小提琴: http : //jsfiddle.net/afzaal_ahmad_zeeshan/nHYhK/1/
I have tested in my Firefox :-) And it works perfect! 我已经在Firefox中进行了测试:-)效果很好!
moz for use mozilla 使用Moz Mozilla
Blockquote
块引用
input:-moz-placeholder { color:transparent; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.