1. 某个ID的元素是否存在 if(window.document.getElementById('someCtl')!=null) { window.document.getElementById('tmenu').style.display = ""; } else { window.document.getElementById('tmenu').style.display = "none"; } 2.日期比较 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title><script language="javascript"> function check() { try { var strdt1=document.getElementById("dt1").value.replace("-","/"); var strdt2=document.getElementById("dt2").value.replace("-","/"); var dt1=new Date(Date.parse(strdt1)); var dt2=new Date(Date.parse(strdt2)); alert(dt1>dt2); } catch(e) { alert("格式错误"+e); } }</script></head><body><form onSubmit="return check();"><input name="dt1" id="dt1" value="2007-9-9" /><input name="dt2" id="dt2" value="2007-10-10"/><input type="submit" value="提交" /></form></body></html> 3.javascript读取select中选择项的value值 document.form1.select1.options[document.form1.select1.selectedIndex].value 转载于:https://www.cnblogs.com/oiea/archive/2007/12/19/966111.html