hover(over, out) event function
When the mouse moves over a matching element, the specified first function will be triggered
When the mouse moves out of this element, the specified function will be triggered The second function
over(function): the function triggered when the mouse moves over the element
out(function): the function triggered when the mouse moves out of the element
<nav class="main-nav"> <a href="/"><span>首页</span></a> <a href="/about"><span>关于考试</span></a> <a href="/exam"><span>报考指南</span></a> <a href="/news"><span>考试情报</span></a> <a href="/career"><span>考试与就业</span></a> <a class="omega" href="/sitemap"><span>网站地图</span></a> </nav> <script> $(function(){
//鼠标移到与移出,移到元素时,添加当前元素样式,并且去掉当前页面的样式。鼠标移出时,去掉当前元素的样式,并且添加当前页面的样式 $('.main-nav').find('a').hover( function(){$(this).addClass('cur');$('.main-nav').find('a[href="<?php echo "/".$path[1];?>"]').removeClass('cur');}, function(){$(this).removeClass('cur');$('.main-nav').find('a[href="<?php echo "/".$path[1];?>"]').addClass('cur');} ); $('.main-nav').find('a[href="<?php echo "/".$path[1];?>"]').addClass('cur'); //加载页面时就添加样式 }); </script>
Get< ;a href="/">This element
$(".main-nav").find('a[href="/"]');
The above article briefly discussing the jQuery hover(over, out) event function is all the content shared by the editor. I hope it can To give you a reference, I also hope that everyone will support the PHP Chinese website.
For more articles related to the jQuery hover(over, out) event function, please pay attention to the PHP Chinese website!