将事件添加到新创建的控件问题... [英] Adding Events to newly created controls question...

查看:72
本文介绍了将事件添加到新创建的控件问题...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难让这段代码工作...... onMouseOver和

onMouseOut事件似乎不会在IE或Mozilla中解雇.....谢谢

提前获得任何帮助...


var imgf = document.createElement(" img");

imgf .src =" ../ files / img.gif";

imgf.style.cursor =" pointer";

imgf.style.border =" 1px纯蓝色" ;;

imgf.title ="日期选择器" ;;


//以下根本不起作用......


imgf.onMouseOver =" this.style.background =''blue'';" ;;

imgf.onMouseOver =" this.style。 background ='''';" ;;

再次感谢!


Michael

I''m having a hard time getting this code to work...the onMouseOver and
onMouseOut events don''t seem to be firing in IE or Mozilla.....thanks
in advance for any assistance...

var imgf = document.createElement("img");
imgf.src = "../files/img.gif";
imgf.style.cursor = "pointer";
imgf.style.border = "1px solid blue";
imgf.title = "Date selector";

// below is not working at all......

imgf.onMouseOver = "this.style.background=''blue'';";
imgf.onMouseOver = "this.style.background='''';";
Thanks again!

Michael

推荐答案

xx********@supergambler.com 写道:
xx********@supergambler.com wrote:
我很难获得这段代码工作... onMouseOver和
onMouseOut事件似乎没有在IE或Mozilla中解雇.....感谢
提前获得任何帮助...

var imgf = document.createElement(" img");
imgf.src =" ../ files / img.gif" ;;
imgf.style.cursor =" pointer" ;;
imgf.style.border =" 1px solid blue";
imgf.title ="日期选择器" ;;

//下面根本不工作... ...

imgf.onMouseOver =" this.style.background =''blue'';" ;;
imgf.onMouseOver =" this.style.background ='' '';" ;;
I''m having a hard time getting this code to work...the onMouseOver and
onMouseOut events don''t seem to be firing in IE or Mozilla.....thanks
in advance for any assistance...

var imgf = document.createElement("img");
imgf.src = "../files/img.gif";
imgf.style.cursor = "pointer";
imgf.style.border = "1px solid blue";
imgf.title = "Date selector";

// below is not working at all......

imgf.onMouseOver = "this.style.background=''blue'';";
imgf.onMouseOver = "this.style.background='''';";



imgf.onmouseover = function(){this.style.backgroundColor =''blue'';}


Mick


imgf.onmouseover = function(){this.style.backgroundColor=''blue'';}

Mick


非常感谢.....到处寻找这个地方....有没有

a好DOM参考你知道的书?或者这样的信息是

位于什么位置?


再次感谢!

Thanks you very much.....looked all over the place for this....is there
a good DOM reference book you know of?? or where info like this is
located?

Thanks again!


Mick White写道:
Mick White wrote:


imgf.onmouseover = function(){this.style.backgroundColor =''blue' ';}


imgf.onmouseover = function(){this.style.backgroundColor=''blue'';}



哎呀,为图像指定背景颜色毫无意义


imgf.onmouseover = function(){this。 parentNode.style.backgroundColor =''blue'';}


Mick


Oops, makes no sense to assign a background colour to an image

imgf.onmouseover = function(){this.parentNode.style.backgroundColor='' blue'';}

Mick


这篇关于将事件添加到新创建的控件问题...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆