jQuery

jQuery

目录
  • jQuery
    • 1. JavaScript和jQuery的关系
    • 2. 获取jQuery
    • 3. jQuery基本公式介绍
    • 4. 选择器
    • 3. 事件
    • 4. 操作DOM
      • 1. 节点文本操作
      • 2. CSS的操作
      • 3. 元素的显示和隐藏
      • 4. 娱乐(测试用)

1. JavaScript和jQuery的关系

jQuery是一个库,里面存在大量的JavaScript函数

2. 获取jQuery

搜索cdn jQuery,复制过来即可




    
    Title
    
    





3. jQuery基本公式介绍

公式:$(selector).action()




    
    Title
    
    
    
    





点我





4. 选择器

//原生的JS,选择器少,麻烦不好记
//标签
document.getElementsByTagName();
//id
document.getElementById();
//类
document.getElementsByClassName();
//jQuery css中的选择器它全部都能用
$('p').click();         //标签选择器
$('#id1').click();      //id选择器
$('.class1').click();   //类选择器

文档工具站:https://css.cuishifeng.cn/index.html

3. 事件

鼠标事件,键盘事件,其他事件

mousedown() 鼠标按下

mousemove() 鼠标移动

mouseover() 点击结束




    
    Title
    
    




mouse: 
点这里移动

4. 操作DOM

1. 节点文本操作




    
    Title
    



  • JavaScript
  • Python

2. CSS的操作

$('#test-ul li[name=python]').css({'color': 'red', 'background': 'blue', 'width': '60px'});

3. 元素的显示和隐藏

本质:display : none;(CSS)

$('#test-ul[name=python]').show();
$('#test-ul[name=python]').hide();

4. 娱乐(测试用)

$(window).width();
$(window).height()

更多函数见上面提到的文档

你可能感兴趣的:(jQuery)