600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > jQuery 鼠标移入移出事件切换

jQuery 鼠标移入移出事件切换

时间:2021-08-11 19:09:31

相关推荐

jQuery 鼠标移入移出事件切换

[html]

<!DOCTYPEhtml>

<html>

<head>

<metacharset="utf-8"/>

<scripttype="text/javascript"src="js/jquery-3.1.1.min.js"></script>

<linkrel="stylesheet"href="css/style.css"/>

<title></title>

<script>

$(function(){

$(msg).on({

mouseover:function(){

$(this).wrap("<h1>");

},

mouseout:function(){

$(this).unwrap();

}

});

});

</script>

</head>

<body>

<pid="msg">HelloWorld!!!</p>

</body>

</html>

hover() 方法规定当鼠标指针悬停在被选元素上时要运行的两个函数。

jQuery 1.7 版本前该方法触发mouseenter 和mouseleave 事件。

jQuery 1.8 版本后该方法触发mouseover 和mouseout 事件。

[html]

<!DOCTYPEhtml>

<html>

<head>

<metacharset="utf-8"/>

<scripttype="text/javascript"src="js/jquery-3.1.1.min.js"></script>

<linkrel="stylesheet"href="css/style.css"/>

<title></title>

<script>

$(function(){

$(msg).hover(

function(){

$(this).wrap("<h1>");

},

function(){

$(this).unwrap();

}

);

});

</script>

</head>

<body>

<pid="msg">HelloWorld!!!</p>

</body>

</html>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。