check if an input field is selected using javascript or jquery -
how can check if input field selected or not, using javascript or jquery ?
any appreciated! thanks!
some googleing found quick solution.
from http://forums.digitalpoint.com/showthread.php?t=77983
there's no built-in way; have use onfocus , onblur events set form of flag each element read.
this script automates process number of forms:
code:
<script type='text/javascript' > /* (c)2006 stephen chalmers * * appends 'hasfocus' flag text/textarea form * elements. * insert script anywhere below last form in document. read current focus state of specified element, use: if( document.forms.myform.myelement.hasfocus ) ... ***/ for(var i=0, df=document.forms, len=df.length; i<len; i++) for(j=0, els=df[i].elements; j<els.length; j++) if( /^text/.test( els[j].type ) ) { els[j].hasfocus=false; els[j].onfocus=function(){this.hasfocus=true;}; els[j].onblur =function(){this.hasfocus=false;}; } </script>
Comments
Post a Comment