新增加一个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(); "/>
可以,注意大小写