diff --git "a/01\347\277\201\347\253\240\345\275\254/\344\275\234\344\270\232/2022-11-23 \344\275\234\344\270\232.md" "b/01\347\277\201\347\253\240\345\275\254/\344\275\234\344\270\232/2022-11-23 \344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..48a4393511ff38bd0b19f58d440a6463bb2d9932 --- /dev/null +++ "b/01\347\277\201\347\253\240\345\275\254/\344\275\234\344\270\232/2022-11-23 \344\275\234\344\270\232.md" @@ -0,0 +1,40 @@ +```html + +``` + +字符串长度 + +```html + +``` + diff --git "a/01\347\277\201\347\253\240\345\275\254/\344\275\234\344\270\232/2022-11-24 \345\234\250\347\272\277\350\241\250\346\240\274\347\274\226\350\276\221.md" "b/01\347\277\201\347\253\240\345\275\254/\344\275\234\344\270\232/2022-11-24 \345\234\250\347\272\277\350\241\250\346\240\274\347\274\226\350\276\221.md" new file mode 100644 index 0000000000000000000000000000000000000000..22d442571407f5e84ecb5a9fb6027552203ae6c9 --- /dev/null +++ "b/01\347\277\201\347\253\240\345\275\254/\344\275\234\344\270\232/2022-11-24 \345\234\250\347\272\277\350\241\250\346\240\274\347\274\226\350\276\221.md" @@ -0,0 +1,23 @@ +```html + +``` + diff --git "a/01\347\277\201\347\253\240\345\275\254/\347\254\224\350\256\260/2022-11-23 \347\254\224\350\256\260.md" "b/01\347\277\201\347\253\240\345\275\254/\347\254\224\350\256\260/2022-11-23 \347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..529f572f50a54a29c00a768e0ff66a8cd1299537 --- /dev/null +++ "b/01\347\277\201\347\253\240\345\275\254/\347\254\224\350\256\260/2022-11-23 \347\254\224\350\256\260.md" @@ -0,0 +1,39 @@ +# jQuery事件 + +在文档加载后激活函数(常用写法) + +``` +$(function(){ + $('#txt').keyup( + function () { + $('#num').text($('#txt').val().length); + } + ) +}); +``` + +### 常用事件 + +**click()**:鼠标单击 + +**contextmenu()**:右键单击菜单(右键菜单按钮时间,可以拒绝右键菜单。) + +**dblclick()**:双击触发 + +**mousedown()**:鼠标按下 + +**mouseup()**:鼠标松开 + +**mousemove()**:鼠标移动 + +**mouseout()**:鼠标移出元素 + +**mouseover()**:鼠标移入元素 + +**keydown()**:按下键盘 + +**keyup()**:按下键盘松开 + +**focus()**:获得焦点 + +**blur()**:失去焦点 diff --git "a/01\347\277\201\347\253\240\345\275\254/\347\254\224\350\256\260/2022-11-24 \347\254\224\350\256\260.md" "b/01\347\277\201\347\253\240\345\275\254/\347\254\224\350\256\260/2022-11-24 \347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..3f4f5ce7307b00fda6ec7eb55453e8a64daf124f --- /dev/null +++ "b/01\347\277\201\347\253\240\345\275\254/\347\254\224\350\256\260/2022-11-24 \347\254\224\350\256\260.md" @@ -0,0 +1,73 @@ +## jQuery + +### 绑定 + +#### 多个事件绑定一个函数 + +```html +bind('事件类型',函数) +``` + +#### 多个事件绑定多个函数(键值对) + +```html +bind({'事件类型': 函数,'事件类型':函数}) +``` + +#### on绑定(动态元素绑定) + +```html +//$(父代选择器) +var text = $(''); +$(function () { + $('td').mousedown(function () { + $(this).append(text); + }) + }) +$(function () { + $('td').on('blur','#text',function () { + text.parent().text(text.val()); + }); + }) +``` + +### 解绑 + +```html +$(function () { + $('td').mousedown(function () { + $(this).append(text); + }).off() + //不带参移除所有事件 + }) +//带参移除特定事件 +``` + +### 一次事件(类似立即执行函数) + +```html +$(function () { + $('td').one(function () { + //当前元素只触发一次该事件 + $(this).append(text); + }) + }) +``` + + + +## hover(鼠标移入移出) + +```html +$(function () { + $('div').hover( + function () { + $(this).css('color','red') + }, + function () { + $(this).css('color','white') + } + ) + }) +``` +