Use JS to set the HTML page mouse hover when changing the background picture

Source: Internet
Author: User

First, each Li is added with a move-in event onmouseover, and the event source is set in the hover event

JS style should be found in the first page of the UL

And then all the li inside the UL

var ln = bg.queryselectorall ("Li");

Get the trigger event element in the Move function

var leg = e.target;//Gets the trigger event element the target event property returns the destination node of the event (the node that triggered the event).

Initialize the background image inside the loop

Set the background picture when hovering the mouse

Event source triggers a mouse hover event

If the background style defined in the initialization is defined in the inline style, then the inline style should be used instead of the class style when the picture is last changed, because the inline style takes precedence over the class style

Element one of an event, event Source:? Refers to the event that the element raises, such as: The event source for this event is event with Target to get the events element two, event:? An event is an action performed, such as: The event is onmouseover () three, the event driver? The result of the execution Example: The background picture of the last set change

Use JS to set the HTML page mouse hover when changing the background picture

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.