Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

dynamically fill bootstrap card

var container = document.querySelector(".container");
for (var i=0; i<tweets.length; i += 1) {
    var name = ' <h4 class="card-title">';
    name += tweets[i].name;
    name += '</h4> </div>';
    var tweet = '<div class="col-xs-12 col-sm-6 col-md-8 col-md-offset-3">'
    tweet += ' <div class="jumbotron">';
    tweet += '  <p  class="card-text">';
    tweet += tweets[i].tweet;
    tweet += "<br>";
    tweet += "</p></div></div>";
    var photo ='<div class="col-md-4 col-md-offset-3"><div class="col-md-4 ">' 
    photo += '  <img class="img-responsive img-circle" src="user/';
    photo += tweets[i].activation;
    photo += '/';
    photo += tweets[i].pic;
    photo += '"></div></div>';

    container.innerHTML+='<div class="card"><div class="card-header">'+
    photo+name+tweet+'</div></div>';
}


//the div in html 
<div class="container">
    <div class="card">
        <div class="card-header">    
            <div class="row">
                <div id="photo">
                    <!-- here  where the pic goes ! -->
                </div>
                <div id="name">
                    <!-- here  where the name goes ! -->
                </div>
            </div>    
            <div class="card-block row">
                <div id="tweet">
                    <!-- here  where the tweet goes ! -->
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<div class="card-block row">    
    <div id="tweet"> </div>
</div>
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs process object 
Javascript :: iterating over an array 
Javascript :: missing state 
Javascript :: constantly send a request until a desired response is recieved expressjs 
Javascript :: random bigint javascript 
Javascript :: go back to screen with params react native 
Javascript :: javascript make variable 
Javascript :: how to check if we reach end of div react hooks 
Javascript :: how can i use two api at the same time in angular 
Javascript :: how to turn a multiple dimensional object into single array 
Javascript :: json data find 
Javascript :: Schalte das jQuery Migrate Script ab 
Javascript :: import all var js 
Javascript :: Cannot resolve name `object`.Flow 
Javascript :: Exponent Power Shorthand in javascript 
Javascript :: different way to for loop js 
Javascript :: reload stylesheet with out refresh page 
Javascript :: trigger many url calls JavaScript 
Javascript :: graphql get item by id from strapi react 
Javascript :: loop featured image react wordpress api 
Javascript :: Finding the longest word in a string 
Javascript :: Javascript Class expressions 
Javascript :: will stop the loop if the array has any negative number and return all the positive numbers before the negative numbers 
Javascript :: mettre en commentaire vscode 
Javascript :: typeorm with better sqlite using query builder 
Javascript :: threejs check if camera is pointing towards object 
Javascript :: node "promise.all" "retry" site:stackoverflow.com 
Javascript :: Example of Logical AND assignment operator in es12 
Javascript :: convert fetch in axios 
Javascript :: vscode react debug chrome profile 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =