列表中输出的twitter profileImages的jquery

列表中输出的twitter profileImages的jquery,jquery,Jquery,我需要一些帮助来重新编写for语句,以便在第一个li上显示一个a href标记,在第二个li上显示两个href标记,在第三个li上显示三个href标记,以此类推,直到项目的完整长度完全填充完毕。我正在尝试以圣诞树格式(三角形)显示twitter个人资料图像 JavaScript var getJasonTweets = function(){ $.getJSON('tweets.json', function(json, textStatus) { /*stuff to

我需要一些帮助来重新编写for语句,以便在第一个li上显示一个a href标记,在第二个li上显示两个href标记,在第三个li上显示三个href标记,以此类推,直到项目的完整长度完全填充完毕。我正在尝试以圣诞树格式(三角形)显示twitter个人资料图像

JavaScript

var getJasonTweets = function(){
    $.getJSON('tweets.json', function(json, textStatus) {
        /*stuff to do after success */
        for (i=0; i<=json.statuses.length; i++){
            var status = json.statuses[i];
            var profileImages = nano("<a href='//twitter.com/statuses/{user.screenName}/{id}'><span class='tree-bauble'><img src='{user.profileImageUrl}' /></span></a>", status);
            // logic
            var li= $('li').append(profileImages);
            $("#twitter-tree").append(li);
        }
    });
};

设法解决它-这是修改后的代码,如果你感兴趣的话

var getJasonTweets = function(){
    $.getJSON('tweets.json', function(json, textStatus) {
        /*optional stuff to do after success */
        var limit = 1;
        var current = 0;
        var li= $('<li></li>');
        for (var i=0; i<json.statuses.length; i++){
            //replaces the normal with bigger
            $('.profileTweetImages').each(function () {
                var profileImage = $(this);
                profileImage.attr('src', profileImage.attr('src').replace('_normal', '_bigger'));
            });
            var status = json.statuses[i];
            var profileImages = nano("<a href='//twitter.com/status/{user.screenName}/{id}'><span class='tree-bauble'><img src='{user.profileImageUrl}' class='profileTweetImages' /></span></a>", status);
            // logic
            li.append(profileImages);
            current++;
            if (current == limit) {
                current = 0;
                limit++;
                $("#twitter-tree").append(li);
                li= $('<li></li>');
            }
        }
    });
};
var getJasonTweets=function(){
$.getJSON('tweets.json',函数(json,textStatus){
/*成功后可选择做的事情*/
风险价值限额=1;
无功电流=0;
var li=$(“
  • ”);
    对于(var i=0;i您的HTML和CSS在哪里?更新为包含HTML和CSS,sorrySo是“树”的格式已经存在并修复了?您不需要创建它,只想将图像放入
    li
    s?是的,这是正确的,我已经在html中构建了一个静态占位符li树,只想在a HREFSA向每个列表项输出50项(来自json)时替换它。。。
            .tree{
            position:relative;
            margin-top:-120px;
            width:100%;
            z-index:0;
            ul{
                list-style-type: none;
                display: block;
                text-align:center;
                margin: 2% auto;
                padding:0;
                li{
                    display: block;
                    width:100%;
                    a{
                        width: 5%;
                        height:0;
                        padding-bottom: 5%;
                        -moz-border-radius: 50%; 
                        -webkit-border-radius: 50%; 
                        border-radius: 50%;
                        background: #4679BD; 
                        display: inline-block;
                        text-align: center;
                        overflow: hidden;
                        margin: 2% 1.5%;
                        -webkit-box-shadow: 7px 7px 5px 0px rgba(90, 90, 90, 0.5);
                        -moz-box-shadow:    7px 7px 5px 0px rgba(90, 90, 90, 0.5);
                        box-shadow:         7px 7px 5px 0px rgba(90, 90, 90, 0.5);
                    }
                    a:nth-child(1){
                        clear:both;
                    }
                }
                li:nth-child(n+1){
                    margin-bottom:1%;
                }
            }
        }
    
    var getJasonTweets = function(){
        $.getJSON('tweets.json', function(json, textStatus) {
            /*optional stuff to do after success */
            var limit = 1;
            var current = 0;
            var li= $('<li></li>');
            for (var i=0; i<json.statuses.length; i++){
                //replaces the normal with bigger
                $('.profileTweetImages').each(function () {
                    var profileImage = $(this);
                    profileImage.attr('src', profileImage.attr('src').replace('_normal', '_bigger'));
                });
                var status = json.statuses[i];
                var profileImages = nano("<a href='//twitter.com/status/{user.screenName}/{id}'><span class='tree-bauble'><img src='{user.profileImageUrl}' class='profileTweetImages' /></span></a>", status);
                // logic
                li.append(profileImages);
                current++;
                if (current == limit) {
                    current = 0;
                    limit++;
                    $("#twitter-tree").append(li);
                    li= $('<li></li>');
                }
            }
        });
    };