JSFiddle - React, Tailwind, and code Playground

by ryanbrill

HTML

<input type="text" name="filter" />
<select>
   
</select>

JavaScript

var from = 10000000000,
to = 20000000000;
for (var i=0; i<500; i++) {
    var rand = Math.floor(Math.random()*(from - to + 1) + to);
    $("select").append('<option value="'+rand+'">'+rand+'</option>');
}

$("input").on("keyup", function() {
    var search = $(this).val();
    $("select option").filter(function() {
        var val = $(this).val();
        if (val.indexOf(search) != 0) {
            $(this).remove();
        }
    });
});