jQuery事件4——hover
生活随笔
收集整理的這篇文章主要介紹了
jQuery事件4——hover
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
作用:將二個事件函數(shù)綁定到匹配元素上,分別當(dāng)鼠標(biāo)指針進入和離開元素時被執(zhí)行(傳兩個參數(shù))
【例】代碼效果
代碼如下
<!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>div {width: 100px;height: 100px;background-color: darkcyan;}.active {width: 105px;height: 105px;background-color: #424242;}</style> </head> <body><div></div> </body> <script src="./jquery.js"></script> <script>$('div').hover(function () {$(this).addClass('active');},function () {$(this).removeClass('active');}) </script> </html>?
總結(jié)
以上是生活随笔為你收集整理的jQuery事件4——hover的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jQuery事件3——trigger触发
- 下一篇: jQuery动画1