jQuery数据类型小结(14个)(2)

var x = [0, 3, 1, 2]; x.reverse() // [2, 1, 3, 0] x.join(" – ") // "2 - 1 - 3 - 0" x.pop() // [2, 1, 3] x.unshift(-1) // [-1, 2, 1, 3] x.shift() // [2, 1, 3] x.sort() // [1, 2, 3] x.splice(1, 2) // 用于插入、删除或替换数组元素,这里为删除从index=1开始的2个元素

9.4 数组为对象,所以始终为true

10. MAP

The map type is used by the AJAX function to hold the data of a request. This type could be a string, an array<form elements>, a jQuery object with form elements or an object with key/value pairs. In the last case, it is possible to assign multiple values to one key by assigning an array. As below: {'key[]':['valuea','valueb']}

11. FUNCTION:匿名和有名两种

11.1 Context、Call和Apply

In JavaScript, the variable "this" always refers to the current context. $(document).ready(function() { // this refers to window.document}); $("a").click(function() { // this refers to an anchor DOM element });

12. SELECTOR

There are lot of plugins that leverage jQuery's selectors in other ways. The validation plugin accepts a selector to specify a dependency, whether an input is required or not:
emailrules: { required: "#email:filled" }
This would make a checkbox with name "emailrules" required only if the user entered an email address in the email field, selected via its id, filtered via a custom selector ":filled" that the validation plugin provides.

13. EVENT

DOM标准事件包括:blur, focus, load, resize, scroll, unload, beforeunload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, andkeyup

14. JQUERY

JQUERY对象包含DOM元素的集合。比如$('p')即返回所有<p>...</p>
JQUERY对象行为类似数组,也有length属性,也可以通过index访问DOM元素集合中的某个。但是不是数组,不具备数组的某些方法,比如join()。

许多jQuery方法返回jQuery对象本身,所以可以采用链式调用:
$("p").css("color", "red").find(".special").css("color", "green");
但是如果你调用的方法会破坏jQuery对象,比如find()和filter(),则返回的不是原对象。要返回到原对象只需要再调用end()方法即可。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgwjxs.html