jQuery笔记
jQuery
1.jQuery初始
JavaScript和jQuery的关系
jQuery相当于JavaScript封装的库
获取jQuery
- 第一种:jQuery官网下载 https://jquery.com/download/
- 第二种:cnd引入 https://www.jb51.net/zt/jquerydown.htm
jQuery API文档
https://jquery.cuishifeng.cn/
jQuery公式
$(selector).action() //公式
例子:
<a href="#" id="test">点我</a>
<script>
//选择器时css的选择器
$('#test').click(function(){
alert('hello,jQuery')
})
</script>
2.jQuery选择器
- css种的选择器jQuery都能用


3.事件
- 鼠标事件,键盘事件,其他事件
获取鼠标坐标
<body>
mouse: <span id="mousemove"></span>
<div id="divmove">
在这里移动试试
</div>
<script>
$(fuction){
$('#divmove').mousemove(function(e){
$('#mousemove').text('x:'+e.pageX + 'y:'+e.pageY)
})
}
</script>
<body>
4.操作DOM
节点文本操作
$('#test').text('abc')
$('#test').html('<strong>abc</strong>')
css操作
$('#test').css({"color","red"})
元素显示和隐藏
//display: none;
$('#test').show()
$('#test').hide()

浙公网安备 33010602011771号