onmouseout怎么弄(html页面问题,如下图,当鼠标移动到选项时,此选项的其他选项就会出现需要怎么弄,最好加上代码)

本文目录
- html页面问题,如下图,当鼠标移动到选项时,此选项的其他选项就会出现需要怎么弄,最好加上代码
- jquery用onmouseout和onmouseover怎么改变span或div中的文字的颜色,大小,粗体,字
- html5 onmouseout怎么使用
- 用onmouseout和onmouseover怎么改变span或div中的文字的颜色、大小、粗体、字体等
html页面问题,如下图,当鼠标移动到选项时,此选项的其他选项就会出现需要怎么弄,最好加上代码
这里介绍两种方式:
一:通过css样式中的 ":hover"实现,代码如下
《!DOCTYPE html》
《html lang="en"》
《head》
《meta charset="UTF-8"》
《title》Document《/title》
《style》
div{
background:red;
width:200px;
height:200px;
}
div:hover{
background:red;
width:500px;
height:500px;
}
《/style》
《/head》
《body》
《div》变大《/div》
《/body》
《/html》
二:通过javascript方式实现,代码如下
《!DOCTYPE html》
《html lang="en"》
《head》
《meta charset="UTF-8"》
《title》Document《/title》
《style》
div{
background:red;
width:200px;
height:200px;
}
.divs{
background:red;
width:500px;
height:500px;
}
《/style》
《/head》
《body》
《div》变大《/div》
《script》
// 首先获取div元素
var divs = document.getElementsByTagName(’div’);
//鼠标移入,将divs的className样式赋给该标签
divs.onmouseover = function () {
this.className = "divs";
}
//鼠标移出,将空的className样式赋给该标签
divs.onmouseout = function () {
this.className = "";
}
《/script》
《/body》
《/html》
jquery用onmouseout和onmouseover怎么改变span或div中的文字的颜色,大小,粗体,字
首先,jQuery中的方法是mouseout和mouseover
onmouseout/onmouseover是javascript的方法
js方法:
var oBox = document.getElementById("box");
oBox.onmouseover = function(){
var oEvent = ev || event;//兼容处理
var oFrom = oEvent.fromElement || oEvent.relatedTarget;//兼容处理
//如果在里面则返回
if(oFrom && oBox.contains(oFrom)){
return;
}
//移入时触发
oBox.style.color="red";//颜色设置
oBox.style.width="100px";//宽度
oBox.style.height="100px"; //高度
oBox.style.font="italic bold 12px arial,serif";//字体
}
oBox.onmouseout = function(){
var oEvent = ev || event; //处理兼容
var oTo = oEvent.toElement || oEvent.relatedTarget; //处理兼容
//如果在里面则返回
if(oTo && oBox.contains(oTo)){
return;
}
//移出时触发
oBox.style.color="black";//颜色设置
oBox.style.width="50px";//宽度
oBox.style.height="50px"; //高度
oBox.style.font="italic bold 12px arial,serif";//字体
}
jQuery方法
var price_tip_pop = null;
$(’#box’).mouseout(function(){
//移出时触发
$(this).css({"color":"black","width":"50px","height":"50px","font":"italic bold 12px arial"});
}).mouseover(function(){
//移入时触发
$(this).css({"color":"red","width":"100px","height":"100px","font":"italic bold 12px arial"});
});
html5 onmouseout怎么使用
onmouseout:当鼠标指针移出图片时运行脚本;
注意: onmouseout 属性不能使用于以下元素: 《base》, 《bdo》, 《br》, 《head》, 《html》, 《iframe》, 《meta》, 《param》, 《script》, 《style》, 或 《title》。
有一个简短的代码:
《!DOCTYPE html》
《html》
《head》
《meta charset="utf-8"》
《title》菜鸟教程(runoob.com)《/title》
《script》
function bigImg(x)
{
x.style.height="64px";
x.style.width="64px";
}
function normalImg(x)
{
x.style.height="32px";
x.style.width="32px";
}
《/script》
《/head》
《body》
《img onmousemove="bigImg(this)" onmouseout="normalImg(this)" border="0" src="smiley.gif" alt="Smiley" width="32" height="32"》
《p》当用户将鼠标移动到图片时触发 bigImg() 函数。该函数使图片变大。《/p》
《p》当用户将鼠标移开时触发normalImg() 函数。该函数使图片变回原来大写。《/p》
《/body》
《/html》
用onmouseout和onmouseover怎么改变span或div中的文字的颜色、大小、粗体、字体等
onmouseover="show()" id="aaa"
show(){
set nnn=document.getElementById("aaa")
nnn.style.background="#ffffff" }诸如此类的用法 当然还有很多 比如在CSS里 例如《style》
.td_mouseover{
background-color:#FF0000;
color:#FFFFFF;
}
.td_normal{
background-color:#FFFFFF;
color:#000000;
}
《/style》
《table》
《tr》
《td onmouseover="this.className=’td_mouseover’;" onmouseout="this.className=’td_normal’;"》
鼠标经过这里背景和文字会变色
《/td》
《tr》
《/table》

更多文章:
delphi数据库案例(请提供一个简单的DELPHI查询数据库的实例,包括所有操作)
2026年4月19日 13:00
ui培训学校排名(请问:惠州UI培训学校排名比较靠前的有哪些)
2026年8月23日 10:15
学生座位随机数生成器(用excel随机排座位号码不要重复的)
2025年6月14日 13:30
用solidworks画大白(大神们这个用solidworks怎么画)
2026年4月17日 21:30
apache恢复默认配置(配置php以后,重启Apache,配置失效了,但重启电脑以后又好了,怎么)
2026年9月5日 07:45
onmousemove怎么停止(js的onmousemove)
2025年8月2日 16:45
三角函数值对照表全部初中(特殊角度的三角函数值是怎么样的呢)
2026年1月3日 15:15













