Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
  <div class="row">
    <div class=" col-12 col-md-2">
      <div class="card px-2">
        <h2 class="text-center">Filter by</h2>
        <hr>
        <h4>Price:</h4>
        <div class="card-body">
          <form id="price-range-form">
            <label for="min-price" class="form-label">Min price: </label>
            <span id="min-price-txt">$0</span>
            <input type="range" class="form-range" min="0" max="99" id="min-price" step="1" value="0">
            <label for="max-price" class="form-label">Max price: </label>
            <span id="max-price-txt">$100</span>
            <input type="range" class="form-range" min="1" max="100" id="max-price" step="1" value="100">
          </form>
        </div>
      </div>
    </div>
    <div class="col-12 col-md-10">
      <div class="card">
        <div class="card-body">
          <div class="row" id="display-items-div">

          </div>
        </div>
      </div>
    </div>
  </div>

</div>
              
            
!

CSS

              
                .product-card {
  margin: 0.4rem 0;
}

.card {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}

              
            
!

JS

              
                let min_price = 0;
let max_price = 100;

$(document).ready(function () {
  showAllItems(); //Display all items with no filter applied
});

$("#min-price").on("change mousemove", function () {
  min_price = parseInt($("#min-price").val());
  $("#min-price-txt").text("$" + min_price);
  showItemsFiltered();
});

$("#max-price").on("change mousemove", function () {
  max_price = parseInt($("#max-price").val());
  $("#max-price-txt").text("$" + max_price);
  showItemsFiltered();
});

let category_items = [
  {
    id: 1,
    category_id: 8,
    price: 39.42,
    title: "Shoes with id #1",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-10", "US-MEN-11"]
  },
  {
    id: 2,
    category_id: 8,
    price: 31.93,
    title: "Shoes with id #2",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-13"]
  },
  {
    id: 3,
    category_id: 8,
    price: 49.44,
    title: "Shoes with id #3",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-14"]
  },
  {
    id: 4,
    category_id: 58,
    price: 65.38,
    title: "Shoes with id #4",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-13"]
  },
  {
    id: 5,
    category_id: 8,
    price: 27.21,
    title: "Shoes with id #5",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-9", "US-MEN-8", "US-MEN-10", "US-MEN-11", "US-MEN-12"]
  },
  {
    id: 6,
    category_id: 8,
    price: 73.05,
    title: "Shoes with id #6",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: [
      "US-MEN-9",
      "US-MEN-8",
      "US-MEN-10",
      "US-MEN-11",
      "US-MEN-12",
      "US-MEN-13"
    ]
  },
  {
    id: 7,
    category_id: 8,
    price: 51.96,
    title: "Shoes with id #7",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-9", "US-MEN-8", "US-MEN-10", "US-MEN-11"]
  },
  {
    id: 8,
    category_id: 8,
    price: 29.35,
    title: "Shoes with id #8",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-11", "US-MEN-12", "US-MEN-13"]
  },
  {
    id: 9,
    category_id: 8,
    price: 80.0,
    title: "Shoes with id #9",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-9", "US-MEN-8", "US-MEN-10", "US-MEN-11"]
  },
  {
    id: 10,
    category_id: 8,
    price: 70.07,
    title: "Shoes with id #10",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-9", "US-MEN-8", "US-MEN-10"]
  },
  {
    id: 11,
    category_id: 8,
    price: 79.37,
    title: "Shoes with id #11",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-9", "US-MEN-8", "US-MEN-10", "US-MEN-11", "US-MEN-12"]
  },
  {
    id: 12,
    category_id: 8,
    price: 27.14,
    title: "Shoes with id #12",
    thumbnail:
      "https://www.transparentpng.com/download/adidas-shoes/a4xO3G-adidas-shoes-adidas-shoe-kids-superstar-daddy-grade.png",
    sizes: ["US-MEN-9", "US-MEN-8", "US-MEN-10", "US-MEN-11"]
  }
];

function showAllItems() {
  //Default grid to show all items on page load in
  $("#display-items-div").empty();
  for (let i = 0; i < category_items.length; i++) {
    let item_content =
      '<div class="col-12 col-md-4 text-center product-card" data-available-sizes="' +
      category_items[i]["sizes"] +
      '"><b>' +
      category_items[i]["title"] +
      '</b><br><img src="' +
      category_items[i]["thumbnail"] +
      '" height="64" width="64" alt="shoe thumbnail"><p>$' +
      category_items[i]["price"] +
      "</p></div>";
    $("#display-items-div").append(item_content);
  }
}

function showItemsFiltered() {
  //Default grid to show all items on page load in
  $("#display-items-div").empty();
  for (let i = 0; i < category_items.length; i++) {
    //Go through the items but only show items that have size from show_sizes_array
    if (
      category_items[i]["price"] <= max_price &&
      category_items[i]["price"] >= min_price
    ) {
      let item_content =
        '<div class="col-12 col-md-4 text-center product-card" data-available-sizes="' +
        category_items[i]["sizes"] +
        '"><b>' +
        category_items[i]["title"] +
        '</b><br><img src="' +
        category_items[i]["thumbnail"] +
        '" height="64" width="64" alt="shoe thumbnail"><p>$' +
        category_items[i]["price"] +
        "</p></div>";
      $("#display-items-div").append(item_content); //Display in grid
    }
  }
}

              
            
!
999px

Console