blurとfocusの運用
2617 ワード
この2つのイベントはinput,spanのような要素だけではない.Windowsにも使えます.
titleを切り替えることができます.
現在のページを切り替えると、titleを変更する文字は「離れた」となる.
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>