Hongmu Notes
Home Language Notes js move the mouse up to modify the style attribute
Language Notes JavaScript

js move the mouse up to modify the style attribute

js move the mouse up to modify the style attribute

Demonstration effect

When the mouse is moved up, the color is displayed in red; when the mouse is moved away, the color is displayed in black.
Get the id object: document.getElementById()
Move the mouse up: onmouseover
Mouse out: onmouseout

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box1{
            height: 30px;
            text-align: center;
            font: 30px/30px "楷体";
        }
    </style>
</head>
<body>
    <div id="box1">
        锣鼓一响,黄金万<span id="span">两</span>
    </div>

    <script>
        document.getElementById("box1").onmouseover = function(){
            document.getElementById("span").style.color = "red";
        };
        document.getElementById("box1").onmouseout = function(){
            document.getElementById("span").style.color = "#000";
        };
    </script>
</body>
</html>
微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Recommended reading

Simple news and information website template – 0800

Simple news and information website template – 0800 Practical Collection Yiyou template

An EyouCMS template designed for clean, news-focused websites. Its minimalist, information-flow design is ideal for publishing news articles, industry updates, trending topics, and in-depth reports. This template helps news websites attract online readers and build media influence. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (Ey...
👁 54
Self-Media News and Information Website Template 0801

Self-Media News and Information Website Template 0801 Practical Collection Yiyou template

This EyouCMS template is ideal for self-media and news/information websites. Its clean, information-flow design is perfect for content creators to publish articles, videos, industry updates, and trending topics. It helps self-media creators build their online brand and attract followers. Template Demo | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (E...
👁 58
Basic Construction Engineering Company Website Template 0802

Basic Construction Engineering Company Website Template 0802 Practical Collection Yiyou template

An EyouCMS website template designed specifically for infrastructure construction companies. Its sophisticated and professional design effectively showcases infrastructure projects, project case studies, and the company's capabilities. This template helps construction firms establish an authoritative online presence and secure more project partnerships. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 53
Resource website typecho001 template

Resource website typecho001 template Program Notes Typecho

typecho001 template template please do not modify the folder name of this template. The folder name is: typecho001 1.4 Fix the js output problem on the article page 1.3 Fix the error prompt when the plug-in is not installed Optimize the list page code output 1.2 Fix the comment function and add a custom homepage title 1.1 Fix the comment reply asymmetry function Add a separate title setting function on the homepage Add the website favicon.ico icon Add one...
👁 198
Light-Gauge Steel Villa Construction and Renovation Website Template – 0803

Light-Gauge Steel Villa Construction and Renovation Website Template – 0803 Practical Collection Yiyou template

This EyouCMS template is ideal for the light-gauge steel villa construction, building, and renovation industries. Its modern and eco-friendly design style is perfect for showcasing light-gauge steel villa products, construction projects, and interior design solutions. It enables new construction enterprises to showcase their green building concepts and capabilities online. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 46
Modification of typecho paging style

Modification of typecho paging style Program Notes Typecho

Sir, times have changed! Typecho is currently the most perfect solution, because Baidu can only see the code of fixed thinking. The actual generated HTML code is breathtakingly clean and fully customized, including adding classes to the li element, adding classes to the a element, adding classes to the previous page and next page, and removing the li tags that come with typecho to express more. I can even add some text to the content inside...
👁 516