亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

jQuery事件方法總結(jié)及測試

原創(chuàng) 2018-12-11 16:43:42 174
摘要:語法:$(document).ready(function(){  }) 不能和<body onload="">一起使用focus()當(dāng)元素獲得焦點(diǎn)change()當(dāng)元素的值發(fā)生改變的時(shí)候click()點(diǎn)擊事件dblclick()雙擊事件mouseover() 當(dāng)鼠標(biāo)指針位于元素上方時(shí)會(huì)發(fā)生mouseover事件mouseenter() 當(dāng)鼠標(biāo)指

語法:

$(document).ready(function(){

  })

 不能和<body onload="">一起使用

focus()當(dāng)元素獲得焦點(diǎn)

change()當(dāng)元素的值發(fā)生改變的時(shí)候

click()點(diǎn)擊事件

dblclick()雙擊事件

mouseover() 當(dāng)鼠標(biāo)指針位于元素上方時(shí)會(huì)發(fā)生mouseover事件

mouseenter() 當(dāng)鼠標(biāo)指針穿過元素時(shí)會(huì)發(fā)生mouseenter事件

mousemove() 當(dāng)鼠標(biāo)指針在指定的元素中移動(dòng)時(shí),就會(huì)發(fā)生該事件

mouseleave() 當(dāng)鼠標(biāo)指針離開元素時(shí)

mouseout() 當(dāng)鼠標(biāo)指針從元素上移開時(shí)

mousedown() 當(dāng)鼠標(biāo)指針移動(dòng)到元素上方并按下鼠標(biāo)按鍵時(shí)

mouseup() 當(dāng)在元素上松開鼠標(biāo)按鍵時(shí)

resize() 當(dāng)調(diào)整當(dāng)前瀏覽器窗口大小時(shí)

pageX()    屬性是鼠標(biāo)指針的位置,相對于文檔的左邊緣 event.pageX event:必須 參數(shù)來自事件綁定函數(shù)

pageY() 屬性是鼠標(biāo)指針的位置,相對于文檔的上邊緣 event.pageY event: 必須 參數(shù)來自事件綁定函數(shù)

<!DOCTYPE html>
<html>
<head>
         <meta charset="utf-8">
         <title>jQuery事件方法</title>
         <script type="text/javascript" src="jquery-3.3.1.min.js"></script>
</head>
<body>
         <script type="text/javascript">
         $(document).ready(function(){
                          /*$('input').blur(function(){
                                   $('input').css('background','red')
                          })
                          $('input').focus(function(){
                                   $('input').css('background','blue')
                          })*/
                          /*$('input').change(function(){
                                   $('input').css('background','pink')
                          })
                          $('button').click(function(){
                                   $('div').css('backgroundColor','blue')
                          })*/
                          /*$('button').dblclick(function(){
                                   $('div').css('backgroundColor','blue')
                          })*/
                          /*$(document).mousemove(function(a){
                                   $('span').text('x:'+a.pageX+'y:'+a.pageY)
                          })
                          n=0;
                          $(window).resize(function(){
                                   $('b').text(n++)
                          })*/
                          /*$('div').mouseenter(function(){
                                   $('div').css('backgroundColor','pink')
                          })
                          $('div').mouseleave(function(){
                                   $('div').css('backgroundColor','blue')
                          })*/
                          /*$('div').mouseout(function(){
                                   $('div').css('backgroundColor','blue')
                          })*/
                          /*$('div').mouseover(function(){
                                   $('div').text('大家好,我是星辰')
                          })*/
                          $('div').mousedown(function(){
                                   $('div').text('按下')
                          })
                          $('div').mouseup(function(){
                                   $('div').text('松開')
                          })
 
                  })
         </script>
         <!-- <input type="text" name="">
         <div style="width:100px;height:100px;background-color:red;margin-top: 20px;"></div>
         <button>點(diǎn)擊</button> -->
         <!-- 鼠標(biāo)位置:<span></span>
         窗口大小被調(diào)整的次數(shù):<b></b> -->
         <div style="width:100px;height: 100px;margin:50px auto;background: red;"></div>
</body>
</html>

                 

發(fā)佈手記

熱門詞條