onmouseout会影响onclick事件 [英] onmouseout affects onclick event
问题描述
您好,
我是Javascript的新手,我遇到了问题。我有一张桌子,如果我将鼠标移动到一排,我希望它变成另一种颜色。为此我使用:
< TR bgColor =''#FFFFE0''
onmouseover =" this.bgColor ='' #F0FAFF''"
onMouseout =" this.bgColor =''#FFFFE0''"> ;.
工作正常,但是现在我希望能够点击一行,使其成为另一种颜色。但是当我使用时:
< TR bgColor =''#FFFFE0''
onmouseover =" this.bgColor ='' #F0FAFF''"
onMouseout =" this.bgColor =''#FFFFE0''"
onclick =" this.bgColor =''#FFFFFF ''">
当我将鼠标移出行时,由于onMouseout,它会变回正常颜色。
有人能告诉我如何解决这个问题吗?
谢谢
Hello,
Im new to Javascript, and I''ve got a problem. I have a table, and if i move my mouse over a row, i want it to turn into another color. for that i use:
<TR bgColor=''#FFFFE0''
onmouseover ="this.bgColor=''#F0FAFF''"
onMouseout ="this.bgColor=''#FFFFE0''">.
That works fine, but now i want to be able to click on a row, to make it another color. But when I use:
<TR bgColor=''#FFFFE0''
onmouseover ="this.bgColor=''#F0FAFF''"
onMouseout ="this.bgColor=''#FFFFE0''"
onclick ="this.bgColor=''#FFFFFF''">
it turns back to the normal color when i move my mouse out of the row, because of the onMouseout.
Can someone tell me how to solve this please?
thanks
推荐答案
Heya,eldin。欢迎来到TSDN!
尝试使用this.style.backgroundColor。
从你在这里发布的内容来看,我可能会做的是:
Heya, eldin. Welcome to TSDN!
Try using this.style.backgroundColor.
From what you''ve posted here, what I would probably do is is:
更改了主题标题。
啊,它的工作原理:D非常感谢
ahh it works :D thanks very much
这篇关于onmouseout会影响onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!