如何使用onmouseover更改文本颜色 [英] How can I use onmouseover to change text color

查看:130
本文介绍了如何使用onmouseover更改文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当鼠标移动到我们公司的名称上时,我希望文本从灰色变为鲜红色。这是不起作用的代码。为了使这项工作需要改变我需要做什么?

I want the text to change from gray to bright red when the mouse is moved over the name of our company. Here is the code that doesn''t work. What do I need to change to make this work?

展开 | 选择 | Wrap | 行号

推荐答案

你的CSS声明(语法)是错误的。


你可以通过使用CSS伪类来避免javascript(除了IE):hover。
your CSS declaration (syntax) is wrong.

you could avoid javascript (except for IE) by using the CSS pseudo-class :hover.
展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


当我尝试你的第二个例子时,我得到了错误ub。是null或不是对象。

When I tried your second example I got the error "ub" is null or not an object.

展开 | 选择 | Wrap | 行号


@andersond


是的,你试图访问一个尚未加载的元素。你需要等待页面完成加载。
@andersond
yup, you tried to access an element, that was not yet loaded. you need to wait ''til the page finished loading.


这篇关于如何使用onmouseover更改文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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