js文本域获得焦点文字消失,失去焦点文字显示

//假设有一个大文本字段,ID名为txt1/**jquery版本*/$('#txt1').focus(function(){$(this).('focus');}).blur(function(){//清除文本$(this).val('');});/**JavaScript版本,代码中绑定*/vartxtareaObj=document.getElementById('txt1');txtareaObj.onfocus=function(){this.value="获取焦点";}txtareaObj.onblur=function(){this.value="";}/**监听版本javascript事件,必须确定浏览器兼容性*/vartxtareaObj=document.getElementById('txt1');//获取函数focusvarfocusHandler=function(){txtareaObj.val('获取焦点');}varBlurHandler=function(){txtareaObj.val('');}try{//Chrome、FireFox、Opera、Safari、IE9。
0及更高版本txtareaObj.addEventListener('focus',foucusHandler,false);txtareaObj.addEventListener('blur',blurHandler,false);}catch(e){//IE8.0及其以下版本txtareaObj.attachEvent('onfocus',handle)txtareaObj.attachEvent('blur',handle);}

文本框获得焦点时,内容逐渐消失;失去焦点时,内容又逐渐出现!最好用jquery实现,谢谢各位高手指教!

我给你写了一篇,你看一下。
我使用的是jquery-1.4.2.min.js,需要自己链接到本地​​jQuery库

jquery表单文本框focus获取焦点后,用什么方法马上就跳出焦点(强制),不让用户输入???

聚焦只会失去焦点

html

jquery

$("#demo").focus(function(){$(this).blur();});