首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

新增加一个DIV,加入方法onclick 可以/onMouseOver不可以?解决办法

2012-04-09 
新增加一个DIV,,加入方法onclick 可以/onMouseOver不可以?inputtype button name aa value aa o

新增加一个DIV,,加入方法onclick 可以/onMouseOver不可以?
<input   type= "button "   name= "aa "   value= "aa "   onclick= "showDiv(); "/>
ABCDE

<script>
function   t1(){
alert( "tt ");
}

function   showDiv(){
var   div   =   document.createElement( "div ");
div.id   = "div1 ";
div.style.top   =   300;
div.style.left   =   300;
div.style.backgroundColor   =   "red ";
div.style.display   =   "inline ";

div.setAttribute( "onMouseOver ",   document.all   ?   eval(function(){t1()})   :   'javascript:t1() ');
div.setAttribute( "onclick ",   document.all   ?   eval(function(){t1()})   :   'javascript:t1() ');

div.innerHTML   =   "hello,   world. ";
document.body.appendChild(div);
}
</script>

---------------
以上代码   onclick   可以/onMouseOver不可以

为什么啊?

[解决办法]
<input type= "button " name= "aa " value= "aa " onmouseover= "showDiv(); "/>

可以,注意大小写

热点排行