Printing HTML Attritbutes with jquery in a loop

i try to loop trough Objects in a Database (parse.com) and would like to print these results with attributes from Bootstrap. I’m a beginner and don’t understand why it’s not possible how i did it. i know there is .attr() but i don’t get it how i can use this in my example.

This is my code:

var Insider = Parse.Object.extend("Insider");


      function getPosts() {
        var query = new Parse.Query(Insider);
        query.find({
            success: function(results) {
                var output = "";

                for (var i in results) {
                    var name = results[i].get("name");
                    var catego = results[i].get("cate");
                    var imageurl = results[i].get("image");  
                    var tpp = results[i].get("tipp");

                        output += "<ul class="media-list">";
                        output += "<li class="media">";
                        output += "<div class="media-left">";
                        output += "<a href="#">";
                        output += "<img id = "" class="media-object"  alt="...">"
                        output += "</a>"
                        output += "</div>"

                }

                $("#list").html(output);
            }, 

            error: function(error){
                console.log("Query error:" + error.message);
            }
        });
      }
            getPosts();

});    

Any help much appreciated!


Source: javascript

Leave a Reply