cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
                <!-- Demo Content -->
  <div class="container">

    <h1>MixItUp: Input Search</h1>
    
    <button class="filter" data-filter="all">All</button>
    <button class="filter" data-filter=".blue">Blue</button>
    <button class="filter" data-filter=".orange">Orange</button>
    <button class="filter" data-filter=".red">Red</button>
    
    <input type="text" id="input" placeholder="Type here">

    <hr>
    <div class="mix blue">
      <p class="title">Red</p>
    </div>
    <div class="mix red">
      <p class="title">Reddit</p>
    </div>
    <div class="mix orange">
      <p class="title">Orange</p>
    </div>
    <div class="mix red">
      <p class="title">Blue</p>
    </div>
    <div class="mix orange">
      <p class="title">Red Rover</p>
    </div>
    <div class="mix blue">
      <p class="title">Ed</p>
    </div>
  </div>
            
          
!
            
              * {
  box-sizing: border-box;
}

.container {
  width: 75%;
  margin: 5em auto;
}

.mix {
  display: none;
  text-align: center;
  width: 23%;
  margin: 1em 1%;
  background-color: #ccc;
}

.blue {
  background-color: blue;
  color: white;
}

.orange {
  background-color: orange;
}

.red {
  background-color: red;
  color: white;
}

button {
  background: #666666;
  border: none;
  color: white;
  padding: .65em;
  border-radius: 5px;
}

input {
  padding: .5em;
}

.title {
  font-weight: 2em;
}
            
          
!
            
              $(function() {

  $(".container").mixItUp();

  var inputText;
  var $matching = $();

  // Delay function
  var delay = (function(){
    var timer = 0;
    return function(callback, ms){
      clearTimeout (timer);
      timer = setTimeout(callback, ms);
    };
  })();

  $("#input").keyup(function(){
    // Delay function invoked to make sure user stopped typing
    delay(function(){
      inputText = $("#input").val().toLowerCase();
      
      // Check to see if input field is empty
      if ((inputText.length) > 0) {            
        $( '.mix').each(function() {
          $this = $("this");
          
           // add item to be filtered out if input text matches items inside the title   
           if($(this).children('.title').text().toLowerCase().match(inputText)) {
            $matching = $matching.add(this);
          }
          else {
            // removes any previously matched item
            $matching = $matching.not(this);
          }
        });
        $(".container").mixItUp('filter', $matching);
      }

      else {
        // resets the filter to show all item if input is empty
        $(".container").mixItUp('filter', 'all');
      }
    }, 200 );
  });
})
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console