这两个事件不仅仅只能运用与input、span之类的元素。还可以运用于window。

可以切换title。

当切换当前页面时,改变title的文字为‘离开了’.

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>select事件</title>
 6 </head>
 7 <body>
 8     <input type="text" value="select事件">
 9     <script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script>
10     <script type="text/javascript">
11         $('input').select(function(event) {
12             $(this).css('background','#999');
13         });
14         var title = $('title').html();
15         $(window).blur( function () { $('title').text('你离开了!') } );
16         $(window).focus(function(){$('title').text(title);})
17     </script>
18 </body>
19 </html>

 

相关文章:

  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2023-03-19
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
相关资源
相似解决方案