javascript 函数

来源:互联网 发布:2018年5g网络 编辑:程序博客网 时间:2024/06/05 04:38
  1. 字符串分割成数组

<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

原创粉丝点击