年前计划之jquery API 重读

既然 工作 卡住了,既然 相关人员 不在,活就不干了 🐢  做一下年前计划

3.X

选择器

:lang(str)    选定包含指定语言的所有元素 匹配语言值等于所提供的语言代码,或以提供的语言代码开始,后面马上跟一个“ - ”的元素   获取这个属性用prop

:header h1~~h7

:root     根元素,永远都是 html

:target   url的哈希值 === 某个元素的id

:contains(txt)  包含指定文本   内容选择器

:has(sel)  匹配含有指定元素的元素

:parent   匹配含有子元素或者文本的元素

:hidden :visible 匹配所有不可见元素,或者type为hidden的元素/匹配所有可见元素  用可见性匹配

[name != str]  [name *= str]  [name ^= str] [name $= str] [name |= str] [name ~= str] 用属性匹配元素

:input   匹配任意类型的input元素  表单属性匹配元素

:text     匹配所有单行文本框  类似的:password :radio :checkbox :submit  :reset  :button :file

:image  匹配所有图像域

扩展:

<input type="image" />
创建一个图像控件,该控件单击后将导致表单立即被提交。

:enabled   匹配所有可用元素  反之的  :disabled

:checked   复选框、单选框等,select中的option

:selected   匹配所有选中的option元素

ajax

$.ajax({
   type: "",
   url: "",
   data: "",
   success: function(data, status, jqXHR){
        this; // 调用本次AJAX请求时传递的options参数
    },
     error: function(request, status, error){
        this; // 调用本次AJAX请求时传递的options参数
    },
   complete: function (request, status) {
        this; // 调用本次AJAX请求时传递的options参数
    }
});    
This is the full list of Ajax events, and in the order in which they are triggered. The indented events are triggered for each and every Ajax request (unless a global option has been set). The ajaxStart and ajaxStop events are events that relate to all Ajax requests together.

ajaxStart (Global Event)
This event is triggered if an Ajax request is started and no other Ajax requests are currently running.
beforeSend (Local Event)
This event, which is triggered before an Ajax request is started, allows you to modify the XMLHttpRequest object (setting additional headers, if need be.)
ajaxSend (Global Event)
This global event is also triggered before the request is run.
success (Local Event)
This event is only called if the request was successful (no errors from the server, no errors with the data).
ajaxSuccess (Global Event)
This event is also only called if the request was successful.
error (Local Event)
This event is only called if an error occurred with the request (you can never have both an error and a success callback with a request).
ajaxError (Global Event)
This global event behaves the same as the local error event.
complete (Local Event)
This event is called regardless of if the request was successful, or not. You will always receive a complete callback, even for synchronous requests.
ajaxComplete (Global Event)
This event behaves the same as the complete event and will be triggered every time an Ajax request finishes.
ajaxStop (Global Event)
This global event is triggered if there are no more Ajax requests being processed.
jQuery.param(obj,traditinal)
Create a serialized representation of an array, a plain object, or a jQuery object suitable for use in a URL query string or Ajax request. In case a jQuery object is passed, it should contain input elements with name/value properties.

.serialize()
Encode a set of form elements as a string for submission.

.serializeArray()
Encode a set of form elements as an array of names and values.

属性:

属性获取之间的差异

css:

offset()  视口偏移,可获取/赋值

position()   获取匹配元素相对父元素的偏移;只对可见元素生效。

文档处理

筛选

.end()  回到最近一个"破坏性"操作之前。

.closest(arg)    从元素本身开始,逐级向上匹配获取第一个匹配元素;

.addBack()      返回当前筛选对象和上一操作筛选出的对象;

.has(selector/element)  筛选出含有特定元素的元素;

.offsetParent()  返回最近的一个定位的祖先元素;   

事件

.change()   仅适用于文本域(text field),以及 textarea 和 select 元素。

.select()    当 textarea 或文本类型的 input 元素中的文本被选择时,会发生 select 事件。

.contextmenu(fn)  鼠标右键事件

效果

JQuery.fx.off  关闭页面上的所有动画,所有效果会立即执行完毕。

工具

$.each(obj|arr,callback(index,value))  遍历对象 类似于javascript的each

$.extend(target,[obj1,obj2...])  扩展对象。或是直接扩展jQuery,类似于Object.assign()

$.grep(arr,fn)  过滤数组   类似于javascript的filter

$.contains(container,contained)   判断是否是某个元素的祖先元素

$.data(element,[key[,value]])  给元素设置数据或获取已设置的数据

$.removeData(element,[key])  删除已设置的数据

$.globalEval(code)   全局执行代码  动态加载外部脚本

$.inArray(value,arr[,fromIndex])     类似于indexOf(),返回值第一处出现的索引

$.isEmptyObject()    检测一个对象是否包含可枚举属性

$.isFunction(value)  判断函数

$.isNumeric()   判断数字

$.isArray()   判断数组

$.isPlainObject(obj)  判断空对象({}或是 new Object())IE8计算失误

$.isWindow(window)  判断当前执行环境是否是 a browser window  ???

$.isXMLDoc(window)  判断当前执行环境是否是XML文档

$.makeArray(obj)   将类数组转化为数组,类似Array.from()

$.map(array,callback(curval,index))  类似javascript的map

$.merge(target,arr1[,arr2...])   合并数组(不去重)

$.noop(fn)   判断空函数

$.parseHTML(data[,context][,keepScripts])  返回dom数组

$.parseJSON(str)  将与json格式匹配的字符串转化成json

$.parseXML() 返回dom数组

$.support   modernizr

$.trim(str)  去首尾空格

$.type(obj)   检测类型

$.uniqueSort(domArr)  dom数组排序并去重,only domArr

回调对象

$.Callbacks()   可以管理多个函数执行

核心

$.holdReady()  保留或是释放jquery就绪的事件  动态脚本加载有用

jQuery.noConflict()  释放 $  变量

jQuery.readyException()  没看懂

jQuery.when()     处理回调,类似于promise

源码地址3.3.1

posted @ 2019-01-24 17:18  Merrys  阅读(178)  评论(0编辑  收藏  举报