People in contact with the work, these functions are less frequently used, I use a few more useful functions to share.
You have what you like, and you can share it.
1.filter 使用了我要什么就有什么
This function not only makes it easy to filter custom HTML, but also allows you to filter json and array
Filter the result of an array of 2
Array
JQuery ([2,3,3]). Filter (function (i,v) {return v==2})
Json
JQuery ([{id:2},{id:3},{id:4}]). Filter (function (i,v) {return v.id==2})
Html
$ ("P"). Filter (function (index) { return $ (this). attr ("id") ==2;});
2, the params mother in also don't need but heart I spell URL
It is easy to spell a collection for MVC to receive and let the traditional url+ "? id=" +id+ "&name=" This code disappear
var myObject = { A: { one:1, two:2, three:3 }, B: [1,2,3]};var recursiveencoded = $.param (myOb ject) var recursivedecoded = decodeURIComponent ($.param (myObject)); alert (recursiveencoded); alert (recursivedecoded );//a%5bone%5d=1&a%5btwo%5d=2&a%5bthree%5d=3&b%5b%5d=1&b%5b%5d=2&b%5b%5d=3//a[one]=1&a [Two]=2&a[three]=3&b[]=1&b[]=2&b[]=3
3,closest mother in also don't need but heart I or to pocket money, Dad don't look for grandpa. Grandpa's not looking for Grandpa's dad, digging a grave without giving me
Closest first checks whether the current element matches, and if so, returns the element itself directly. If it does not match, look up the parent element, one layer at a level, until the element that matches the selector is found. If nothing is found, an empty jquery object is returned.
Several functions of jquery that are more practical, but that many people ignore