日期:2014-05-16  浏览次数:20336 次

求助ver xx = document.getElementById 问题
现在代码:

if(   document.getElementById( "name ")   )
{
document.getElementById( "div_name_ ").innerHTML   =   "Please   Insert   Name! "   ;
document.getElementById( "name ").focus();
return   false;
}


想改为:
----------------------------

var   dg   =   document.getElementById
if(   dg( "name ")   )
{
dg( "div_name_ ").innerHTML   =   "Please   Insert   Name! "   ;
dg( "name ").focus();
return   false;
}

----------------------------

在IE下好用,FF下所有效果丢失

------解决方案--------------------
var dg = function(id){return document.getElementById(id);} 试试