摘要:<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jq的事件</title> <style type="text/css"> div{ width:200px; height:200px; background:pink; text-align: center; margin: 20px auto; } </style> <script src="../jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(document).ready(function(){ // .hover(over,out) //鼠标移出移进的事件 $('div').hover( function(){ $(this).css({ 'border':'2px solid #999', 'borderRadius':'15px', 'box-shadow':'2px 2px 15px #999', 'color':'#fff', 'fontweight':'bold' }) }, function(){ $(this).css({ 'border':'none', 'borderRadius':'0px', 'box-shadow':'none', 'color':'#000', 'fontweight':'400' }) } ) $(document).mousemove(function(aa){ $('span').text('当前鼠标位置为X:'+aa.pageX+","+"y:"+aa.pageY); }) }) </script> </head> <body> <div>移动到该元素上<br><span></span></div> </body> </html>