- 字符串分割成数组
<script type="text/javascript">
function explode(inputstring, separators, includeEmpties) {
inputstring = new String(inputstring);
separators = new String(separators);
if(separators == "undefined") {
separators = " :;";
}
fixedExplode = new Array(1);
currentElement = "";
count = 0;
for(x=0; x < inputstring.length; x++) {
str = inputstring.charAt(x);
if(separators.indexOf(str) != -1) {
if ( ( (includeEmpties <= 0) || (includeEmpties == false)) && (currentElement == "")) {
}
else {
fixedExplode[count] = currentElement;
count++;
currentElement = "";
}
}
else {
currentElement += str;
}
}
if (( ! (includeEmpties <= 0) && (includeEmpties != false)) || (currentElement != "")) {
fixedExplode[count] = currentElement;
}
return fixedExplode;
}
var aq = explode("aaaaa#bbbbb#cccc", '#');
</script>
js 获取radio的值,MD,找了很多个版本终于成功一个。 版本: v1.3.2
alert($("input[name='gender']:checked").val());
$("input[name='gender']:checked").val() == undefined