<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>demo</title>
    <script type="text/javascript" src="jquery-1.12.4.js"></script>
</head>
<body>
    <ul>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
            <input name="button" type="button" class="list-button" value="修改" />
            <input name="button" type="button" class="list-button" value="删除" />
            <input name="button" type="button" class="list-button" value="提交" />
            <input name="button" type="button" class="list-button" value="more" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
            <input name="button" type="button" class="list-button" value="修改" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
            <input name="button" type="button" class="list-button" value="查看" />
            <input name="button" type="button" class="list-button" value="查看" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
            <input name="button" type="button" class="list-button" value="修改" />
            <input name="button" type="button" class="list-button" value="删除" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
            <input name="button" type="button" class="list-button" value="修改" />
            <input name="button" type="button" class="list-button" value="删除" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
            <input name="button" type="button" class="list-button" value="修改" />
            <input name="button" type="button" class="list-button" value="删除" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
            <input name="button" type="button" class="list-button" value="修改" />
            <input name="button" type="button" class="list-button" value="删除" />
            <input name="button" type="button" class="list-button" value="提交" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
            <input name="button" type="button" class="list-button" value="修改" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
        </li>
        <li class='czbtn'>
            <input name="button" type="button" class="list-button" value="查看" />
            <input name="button" type="button" class="list-button" value="修改" />
        </li>
    </ul>
</body>
<!-- 动态获取 -->
<script>
    var ww=[];
    console.log('wo');
    var showCZ=$('.czbtn');
    for (i=0;i<showCZ.length;i++) {
        console.log($('.czbtn').eq(i).children("input").length);
        var total=$('.czbtn').eq(i).children("input").length;
        ww.push(total);
    }
    console.log(ww);
    console.log("Max:"+Math.max.apply(null, ww));//最大值
    console.log("Min:"+Math.min.apply(null, ww));//最小值
    
</script>
</html

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script>
    var arr   = ["a","x","b","d","m","a","k","m","p","j","a"];
    var count = {};
    var pos   = {};
    //遍历arr,统计每个字母出现次数且记录位置
    arr.forEach(function(value, index){
        if(count[value]){
            count[value] ++;
            pos[value] += ","+index; 
        } else {
            count[value] = 1;
            pos[value]   = ""+index;
        }
    });
    console.log(count);
    console.log(pos);
    
    //获取出现最多的字母
    var max = 0;
    var letter;
    for(i in count){
        if(count[i] > max ){
            max    = count[i];
            letter = i; 
        }
    }
    
    console.log("最多的是:" + letter);
    console.log("位置分布:" + pos[letter]);
</script>
</body>
</html>

标签:jQuery

你的评论