jq事件方法

Original 2018-11-06 16:35:13 376
abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jq事件</title> <script src="jquery-3.3.1.min.js"> </scrip
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jq事件</title>
<script src="jquery-3.3.1.min.js"> </script>

</head>
<body>
<script>
//语法 $('选择器').事件(funtion(){
// $('选择器').改变的属性('','')    })
//blur失去焦点
//focus()获取焦点
//change 值发生变化
//click 单击
//dblclick 双击
//mousemove鼠标移上
$(document).ready(function(){
// $('input').focus(function(){
//  $('input').css('background','red')

// })
$('input').change(function(){
$('input').css('background','pink')
})
$('button').click(function(){
$('#div').css('background','blue')
})
$(document).mousemove(function(xy){
$('span').text('x值:'+xy.pageX+'y:'+xy.pageY)
})


})


</script>
<input type="text">
<div id="div" style="width: 100px; height: 100px; background: red;margin-top: 20px;"></div>
<button>点击</button>

<div>
当前鼠标的位置: <span></span>

</div>
</body>
</html>

语法 $('选择器').事件(funtion(){

 $('选择器').改变的属性('属性名','修改值')    })

用到的方法 blur失去焦点,focus()获取焦点 change 当值发生变化

click 单击  dblclick 双击    mousemove鼠标移上

通过$就能获取选择器,语法比js要方便

Release Notes

Popular Entries