æå车é®åè·³å°ä¸ä¸æ§ä»¶ var elemType;//éä¸æ§ä»¶ç±»å var elemObj; //éä¸æ§ä»¶å¯¹è±¡ function enterKey() { //è·å页é¢æææ§ä»¶ var elems = document.forms[0].elements; var len=elems.length; //设置å车é®è·³è·çæ§ä»¶ç±»å var elemTypeAry =["text","textarea","select-one","button","radio","checkbox"]; var elemTypeStr=elemTypeAry.join(""); for(var i=0;i<len;i++){ //è·åæ§ä»¶ç±»å elemType=elems[i].type; //è¥æ¯å表ä¸çç±»åæ§ä»¶åä¸ºå ¶æ³¨åäºä»¶ if(elemTypeStr.indexOf(elemType)!=-1){ //æ§ä»¶è·å¾ç¦ç¹åä¸ºå ¨å±åéèµå¼ elems[i].onfocus=function(){ //è¥å½åæé®ä¸ºtypeBtnåä¸ä¸ºå ¶æ³¨åonfocusäºä»¶ if(this.id=="typeBtnId")return; //è·å¾å½åæ§ä»¶ç±»å elemType=this.type; //è·å¾å½åæ§ä»¶å¯¹è±¡ elemObj=this; } //è¥æé®ä¸ºEnteråæ¹ä¸ºTabå³è·³å°ä¸ä¸æ§ä»¶ elems[i].onkeydown=function(){ if(event.keyCode==13)event.keyCode=9 }; } } } //æ¾ç¤ºå½åéä¸æ§ä»¶ç±»å function getType(){ alert(elemType); //ç±äºç¹å»æé®åæé®è·å¾ç¦ç¹æéè¦å°ç¦ç¹é置为ä¹åçæ§ä»¶ä¸ elemObj.focus(); } 123 456 [Ctrl+A å ¨é 注:å¦éå¼å ¥å¤é¨Jséå·æ°æè½æ§è¡]