<script type="text/javascript" src="../js/jquery-1.12.4.min.js"></script>
? <script type="text/javascript">
? ? ? $(function(){
? ? ? ? $('#text01').focus(function () {
? ? ? ? ? ? alert('獲取焦點');
? ? ? ? });//網(wǎng)頁顯示獲取焦點
? ? ? ? $('#text01').blur(function () {
? ? ? ? ? ? alert('失去焦點');
? ? ? ? });
? ? ? ? // $('#txt01').focus();
? ? ? ? //自動獲取焦點
? ? ? ? // $('#txt01').change(function () {
? ? ? ? //? ? alert('值變了');
? ? ? ? //? ? // change 表單元素的值發(fā)生變化 失去焦點才會被觸發(fā)
? ? ? ? // }) //檢測用戶名是否存在 用戶名全部輸完才會檢測 高頻觸發(fā)
? ? ? ? ? $('#txt01').keyup(function () {
? ? ? ? ? ? alert('鍵盤松開了');
? ? ? ? ? ? //松開鍵盤會彈出 輸入字母就會彈出
? ? ? ? ? });
? ? ? ? $(document).ready(function () {
? ? ? ? ? ? //DOM 加載完成
? ? ? ? });
? ? ? ? $(function () {});//簡寫
? ? ? ? window.onload = function(){};//原生js寫法
? ? ? ? $(window).load(function () {
? ? ? ? //元素加載完成
? ? ? ? });
? ? ? ? $(window).resize(function () {
? ? ? ? ? ? console.log('窗口尺寸變化了');
? ? ? ? ? ? //瀏覽器窗口尺寸改變
? ? ? ? })//高頻觸發(fā)工具 手機端用的較多
? ? ? })
? </script>
</head>
<body>
? <input type="text" id="txt01" autofocus>
<!--autofocus 頁面自動獲取焦點-->
</body>