MOOTOOLS JS-清除输入字段onClick onFocus on click focus active
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MOOTOOLS JS-清除输入字段onClick onFocus on click focus active相关的知识,希望对你有一定的参考价值。
// 201004291250 - Mootools clear input on focus, return default value if no data entered // FROM: Clear text field with mootools on focus. - MooTools Users | Google Groups http://bit.ly/cHPev3 /* I've got this snippet that will clear the value on focus and if the value of the focus is '' it will put the default value again in the input. You will need the default value to be on an attribute of the input, like alt or anyother (if you don't bother about validation). Fábio Miranda Costa Engenheiro de Computação http://meiocodigo.com */ // FUNCTION: Element.implement({ clearFocusResetBlur: function(attr){ var valueString = this.get(attr); this.addEvents({ 'focus': function(){ if( this.get('value') == valueString ) this.set('value',''); }, 'blur': function(){ if( this.get('value') == "" ) this.set('value',valueString); } }); } }); // Usage // html: // <input id="input_id" value="some value" alt="default value" /> // JS: $('.jform form .cleardefault').set('alt','value').clearFocusResetBlur('alt');
以上是关于MOOTOOLS JS-清除输入字段onClick onFocus on click focus active的主要内容,如果未能解决你的问题,请参考以下文章
JS-onclick函数将文本字符符号插入到光标处的文本输入字段或文本区域