Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

using javascript array create bootstrap card

var items = [
  ['Logitek', 'Rp 60.000,00', 'Logitek Keyboard', 'logitek.jpeg'],
  ['MSI', 'Rp 300.000,00', 'MSI Keyboard', 'msi.jpeg'],
  ['Genius', 'Rp 50.000,00', 'Genius Mouse', 'genius.jpeg'],
  ['Jerry', 'Rp 30.000,00', 'Jerry Mouse', 'jerry.jpeg']
]

let content = '';

items.forEach(p => {
  content += `
    <div id="keyBoard" class="col-md-4 mt-2">
              <div class="card" style="width: 18rem;">
                  <img src="${p[3]}" class="card-img-top img-fluid" alt="keyboard">
                  <div class="card-body">
                      <h5 class="card-title" id="itemName">${p[0]}</h5>
                      <p class="card-text" id="itemDesc">${p[2]}</p>
                      <p class="card-text">${p[1]}</p>
                      <a href="#" class="btn btn-primary" id="addCart">Add to cart</a>
                  </div>
              </div>
          </div>
  `
});

document.querySelector("#shop").innerHTML = content;
Comment

using javascript array create bootstrap card

var items = [
  ['Logitek', 'Rp 60.000,00', 'Logitek Keyboard', 'logitek.jpeg'],
  ['MSI', 'Rp 300.000,00', 'MSI Keyboard', 'msi.jpeg'],
  ['Genius', 'Rp 50.000,00', 'Genius Mouse', 'genius.jpeg'],
  ['Jerry', 'Rp 30.000,00', 'Jerry Mouse', 'jerry.jpeg']
]

let content = '';

items.forEach(p => {
  content += `
    <div id="keyBoard" class="col-md-4 mt-2">
              <div class="card" style="width: 18rem;">
                  <img src="${p[3]}" class="card-img-top img-fluid" alt="keyboard">
                  <div class="card-body">
                      <h5 class="card-title" id="itemName">${p[0]}</h5>
                      <p class="card-text" id="itemDesc">${p[2]}</p>
                      <p class="card-text">${p[1]}</p>
                      <a href="#" class="btn btn-primary" id="addCart">Add to cart</a>
                  </div>
              </div>
          </div>
  `
});

document.querySelector("#shop").innerHTML = content;
Comment

PREVIOUS NEXT
Code Example
:: jquery check if input is empty on keyup 
::  
Javascript :: yup test string async 
Javascript :: Which condition will print hello? var a=2; var b=3; if(a___?___b){console.log(“Hello”);} 
Javascript :: super in javascript 
Javascript ::  
::  
Javascript :: javascript how to convert string to number 
:: socket ERR_CONNECTION_REFUSED 
Javascript ::  
::  
Javascript ::  
:: .html jquery in javascript 
:: how to assign empty function in react component props 
Javascript ::  
Javascript ::  
Javascript :: apollo graphql 
::  
Javascript :: express alternatives 
::  
Javascript :: javascript declare empty array 
::  
Javascript ::  
::  
Javascript :: Find All Less Than Equal To In MongoDB 
::  
Javascript :: python json nested dictionaries 
Javascript :: how to make a field not required with joi 
Javascript ::  
:: vue route automatic redirect 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =