jQuery中的正则表达式

在jQuery中是通过正则表达式来找到某一个dom节点,你可以使用xpath的一些技巧用在jQuery上。
在jQuery源码中最开始的地方有这一行代码:
// A simple way to check for HTML strings or ID strings (both of which we optimize for)
var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/, // Is it a simple selector
isSimple = /^.[^:#\[\.]*$/, // Will speed up references to undefined, and allows munging its name.
undefined;
继续阅读…
Recent Comments