On Mouseover, the label is moved when the td contains the label.

Source: Internet
Author: User

This is because when you move the mouse over a in td, The onmouseout event of td will be triggered.
Then, onmouseover of a is triggered, and the event transfer chain is sent up to td.
Onmouseover is triggered again, so it will flash.

There are two solutions: first, in onmouseout of td, you can determine event. srcElement to see if it is included in td:

Function ChangeColor (bDirection)
{
If (! BDirection) // onmouseout is triggered
{
If (event. srcElement. contains (event. toElement) return; // It is a sub-object and is not operated.
.....
}
}

<Td onmouseout = "ChangeColor (false)" onmouseover = "ChangeColor (true)"> <a> hello </a> </td>


//////////////////////////////////////// ////////

Veryhuo.com

Parsing javascript event Events

Describes the status of an event, such as the element that triggers the event object, the location and status of the mouse, and the key that you press. The event object is valid only when an event occurs. Some Properties of the event only make sense for specific events. For example, the fromElement and toElement attributes only make sense for onmouseover and onmouseout events. In the example below, check whether the mouse is clicked on the link. If the shift key is pressed, the link jump will be canceled. <HTML>
<HEAD> <TITLE> Cancels Links </TITLE>
<Script language = "JScript">
Function cancelLink (){
If (window. event. srcElement. tagName = "A" & window. event. shiftKey)
Window. event. returnvalue = false;
}
</SCRIPT>
<BODY onclick = "cancelLink ()"> the following example shows the current position of the mouse on the status bar. <BODY onmousemove = "window. status = 'X = '+ window. event. X + 'y =' + window. event. Y"> liehuo.net
Attributes: altKey, button, Member, clientX, clientY, ctrlKey, fromElement, keyCode, offsetX, offsetY, propertyName, returnvalue, screenX, screenY, delimiter, srcElement, srcFilter, toElement, type, x, y ---------------------------------------------------------------------------------- 1. altKey
Description:
Check the status of the alt key. Syntax:
Possible values of event. altKey:
When the alt key is pressed, the value is TRUE; otherwise, the value is FALSE. Read-only.
2. button
Description:
Check the pressed mouse key. Syntax:
Possible values of event. button:
0 without buttons
1 left click
2. Right-click
3. Press the Left or Right key.
4. Press the intermediate key
5. Press the left and intermediate keys.
6. Right-click and select intermediate key.
7. Press all keys. This attribute is only used for onmousedown, onmouseup, and onmousemove events. For other events, 0 (such as onclick) is returned regardless of the mouse status ). 3. cancelBubble
Description:
Checks whether events of the upper layer are controlled. Syntax:
Event. cancelBubble [= cancelBubble] possible values:

Lie # fire # Network


This is a read-write Boolean value: TRUE is not controlled by the event of the Upper-layer element.
FALSE allows the event to be controlled by the upper-layer element. This is the default value. Example:
The following code snippet demonstrates how to cancel showSrc () triggered by event onclick on the upper-Layer Element (body) if the shift key is also pressed when you click onclick on the image () function. <Script language = "JScript">
Function checkCancel (){
If (window. event. shiftKey)
Window. event. cancelBubble = true;
}
Function showSrc (){
If (window. event. srcElement. tagName = "IMG ")
Alert (window. event. srcElement. src );
}
</SCRIPT>
<BODY onclick = "showSrc ()">

4. clientX
Description:
Returns the X coordinate of the mouse in the client area of the window. Syntax:
Event. clientX notes:
This is a read-only attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse.
5. clientY
Description:
Returns the Y coordinate of the mouse in the client area of the window. Syntax:
Event. clientY notes:
This is a read-only attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse. Liehuo.net
6. ctrlKey
Description:
Check the status of the ctrl key. Syntax:
Possible values of event. ctrlKey:
When the ctrl key is pressed, the value is TRUE; otherwise, the value is FALSE. Read-only.
7. fromElement
Description:
Detects the elements that the mouse leaves when the onmouseover and onmouseout events occur. Refer to: 18. toElement Syntax:
Event. fromElement notes:
This is a read-only attribute.
8. keyCode
Description:
(See http://www.joyist.com/forum/showto... ID = 31 & Forum_ID = 2)
Detects the internal code corresponding to the keyboard event.
This attribute is used for onkeydown, onkeyup, and onkeypress events. Syntax:
Event. keyCode [= keyCode]
Possible values:
This is a readable value and can be any Unicode keyboard internal code. If no keyboard event is triggered, the value is 0.
9. offsetX
Description:
Check the horizontal coordinate syntax of the mouse position relative to the object that triggers the event: liehuo.net
Event. offsetX
10. offsetY
Description:
Check the vertical coordinate syntax of the mouse position relative to the trigger event object:
Event. offsetY
11. propertyName
Description:
Sets or returns the name of an element's changed attribute. Syntax:
Event. propertyName [= sProperty] possible values:
SProperty is a string that specifies or returns the name of the attribute changed by the element that triggers the event.
This attribute can be read and written. No default value. Note:
You can use the onpropertychange event to obtain the value of propertyName. Example:
The following example uses the onpropertychange event to display the value of propertyName in a dialog box. <HEAD>
<SCRIPT>
Function changeProp ()
{
BtnProp. value = "This is the new value ";
} Function changeCSSProp ()
{
BtnStyleProp. style. backgroundColor = "aqua ";
}
</SCRIPT>
</HEAD>
<BODY>
<P> The event object property propertyName is
Used here to return which property has been
Altered. </P> <input type = button ID = btnProp onclick = "changeProp ()" Lie-fire-Net
Value = "Click to change the value property of this button"
Onpropertychange = 'alert (event. propertyName + "property has changed value") '>
<Input type = button ID = btnStyleProp
Onclick = "changeCSSProp ()"
Value = "Click to change the CSS backgroundColor property of this button"
Onpropertychange = 'alert (event. propertyName + "property has changed value") '>
</BODY>
12. returnvalue
Description:
Set or check the Value Syntax returned from the event:
Event. returnvalue [= Boolean] possible values:
The value in the true event is returned.
False: the default operation of events on the source object is canceled. For example, see the beginning of this article.
13. screenX
Description:
Syntax for detecting the horizontal position of the mouse relative to the user's screen:
Event. screenX
Note:
This is a read-only attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse.
14. screenY
Description:
Syntax for detecting the vertical position of the mouse relative to the user screen:
Event. screenY notes:
This is a read-only attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse.

Liehuo.net


15. shiftKey
Description:
Check the status of the shift key. Syntax:
Possible values of event. shiftKey:
When the shift key is pressed, the value is TRUE; otherwise, the value is FALSE. Read-only.
16. srcElement
Description:
Returns the element of the trigger event. Read-only. For examples, see the beginning of this article. Syntax:
Event. srcElement
17. srcFilter
Description:
Returns the filter that triggers the onfilterchange event. Read-only. Syntax:
Event. srcFilter
18. toElement
Description:
Detects the elements that the mouse enters when the onmouseover and onmouseout events occur. Reference: 7. fromElement Syntax:
Event. toElement annotation:
This is a read-only attribute. Example: The following Code demonstrates that when you move the mouse over the button, a dialog box is displayed, showing "mouse arrived" <SCRIPT>
Function testMouse (oObject ){
If (oObject. contains (event. toElement) {liehuo.net
Alert ("mouse arrived ");
}
}
</SCRIPT>
:
<Button id = oButton onmouseover = "testMouse (this)"> Mouse Over This. </BUTTON>
19. type
Description:
Event name returned. Syntax:
Event. type annotation:
The name of an event without a prefix of "on" is returned. For example, the type returned by the onclick event is click.
Read-only.
20. x
Description:
Returns the x-axis coordinates of the upper-level elements with the position attribute relative to the css attribute. If there is no upper-level element with the position attribute in the css attribute, the BODY element is used as the reference object by default. Syntax:
Event. x notes:
If the mouse moves out of the window after an event is triggered, the returned value is-1.
This is a read-only attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse.
21. y
Description:
Returns the Y axis coordinate of the parent element with the position attribute relative to the css attribute. If there is no upper-level element with the position attribute in the css attribute, the BODY element is used as the reference object by default. Syntax:
Event. y notes:
If the mouse moves out of the window after an event is triggered, the returned value is-1.
This is a read-only attribute. This means that you can only use it to get the current position of the mouse, but you cannot use it to change the position of the mouse. Veryhuo.com

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.