jQuery获取/改变CSS
jQuery操作属性的方法
jQuery事件方法
jQuery事件切换:hover(over,out)鼠标移上效果和鼠标移出效果。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <script type="text/javascript" src="jquery-3.4.0.min.js"> </script> <style type="text/css"> div{width:200px;height:200px;border:1px solid #0F0} </style> <body> <script type="text/javascript"> $(document).ready(function(){ $('div').hover( function(){ $(this).css('background','red') }, function(){ $(this).css('background','blue') } ) }) </script> <div>我是内容</div> </body> </html>