是否有比我所拥有的更好的方式(例如通过正则表达式)转向
"div#container.blue"
进入这个
["div","#container",".blue"];
这就是我所拥有的……
var arr = []; function process(h1,h2) { var first = h1.split("#"); arr.push(first[0]); var secondarr = first[1].split("."); secondarr[0] = "#" + secondarr[0]; arr.push(secondarr[0]); for (i = 1; i< secondarr.length; i++) { arr.push(secondarr[i] = "." + secondarr[i]); } return arr; }