zoukankan      html  css  js  c++  java
  • 留言本,keyCode

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题pj文档</title>
    <script>
    window.onload = function() {
    	var oText=document.getElementById('text1');
    	var oUl=document.getElementById('ul1');
    	
    	oText.onkeyup=function(ev)
    	{
    		ev=ev||event;
    		
    		if(oText.value!='')
    		{
    			if (ev.keyCode == 13) {
    			
    				var oLi = document.createElement('li');
    				oLi.innerHTML = oText.value;
    				
    				if ( oUl.children[0] ) {
    					oUl.insertBefore( oLi, oUl.children[0] );
    				} else {
    					oUl.appendChild( oLi );
    				}
    				
    			}
    		}
    	}
    	
    	
    };
    </script>
    </head>
    
    <body>
    	<input type="text" id="text1"/>
    	<ul id="ul1" ></ul>
    </body>
    </html>
    

      

  • 相关阅读:
    PowerDesigner11.0的SQL生成表,写列描述出错
    centos中crontab(计时器)用法详解
    5.14
    4.13
    5.15
    监听服务启动失败
    4.24
    Enjoy 4.26
    4.14
    export
  • 原文地址:https://www.cnblogs.com/hduhdc/p/5420134.html
Copyright © 2011-2022 走看看