动态为FORM中的元素添加行为

xiaoxiao2022-06-12  70

<SCRIPT LANGUAGE="JavaScript"><!--//动态的为FORM中的元素添加行为function check(){ var tag=document.getElemetnsByTagName("input"); if(tag.length>0){ for(var i=0;i<tag.length;i++){ if(tag[i].type="text"){ tag[i].setAttribut ("onkeypress",document.all?eval(function(){whenEnterSubmit(event)}): "javascript:whenEnterSubmit(event)"); } } }}function whenEnterSubmit(e){var e=e||event;if(e.keyCode==13){//回车 document.form.submit(); }}//--></SCRIPT>由于是在网吧写的没有进行调试,可能存在BUG,望见谅!但是这是我在工程里成功实现的,是可以用的!
转载请注明原文地址: https://www.6miu.com/read-4933274.html

最新回复(0)