zoukankan      html  css  js  c++  java
  • jQuery拆分字符串 split()并且遍历$.each()

    1.拆分字符串

    语法:字符串名.split(separator,howmany)

    separator 必需。字符串或正则表达式,从该参数指定的地方分割 stringObject。

    howmany 可选。该参数可指定返回的数组的最大长度。如果设置了该参数,返回的子串不会多于这个参数指定的数组。如果没有设置该参数,整个字符串都会被分割,不考虑它的长度。

    该方法会得到一个字符串数组

    var chaoxiang = "${authElecEntrust.orientation}";
                    var arr = chaoxiang.split('、');
                    $.each(arr,function (index,obj) {
                        $("input:checkbox[name='chaoxiang'][value="+obj+"]").attr("checked", "true");
                    })

    2.遍历

    $.each(数组名,function(index,obj){})

    index通常为数组里面对象的索引,而obj为当前遍历到的对象

  • 相关阅读:
    各种集群服务
    cdn
    网页请求的完整过程
    html
    ajax异步请求技术
    浅谈前端渲染与后端渲染的区别
    html与php
    Ubuntu安装anaconda3
    win10安装Ubuntu系统
    删除排序数组中的重复项
  • 原文地址:https://www.cnblogs.com/pypua/p/13150387.html
Copyright © 2011-2022 走看看