1
var temp = "/User/Create";
alert(temp.count("/")); //should output '2' find '/'
我會嘗試這種方式計特殊字符jQuery中
// the g in the regular expression says to search the whole string
// rather than just find the first occurrence
// if u found User -> var count = temp.match(/User/g);
// But i find '/' char from string
var count = temp.match(///g);
alert(count.length);
ü可以嘗試這裏http://jsfiddle.net/pw7Mb/
http://jsfiddle.net/pw7Mb/2/ – Imdad 2012-07-26 06:26:25