Last active
August 29, 2015 14:03
-
-
Save thotbox/258ab7dcf990669e1fff to your computer and use it in GitHub Desktop.
JavaScript: Combo Box Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Combo Box | |
$(document).ready(function() { | |
$('#providers li').click(function(e) { | |
$('#provider').val($(this).text()).change(); | |
setTimeout(function () { | |
$('#provider-list').hide(); | |
}, 300); | |
}); | |
$('#provider').blur(function() { | |
setTimeout(function () { | |
$('#provider-list').hide(); | |
}, 300); | |
}); | |
}); | |
// Subscribe Filter | |
$('#provider').keyup(function() { | |
var filter = $(this).val(); | |
if ( filter !== '' ) { | |
$('#provider-list').show(); | |
} | |
$('#providers li').each(function() { | |
if ($(this).text().search(new RegExp(filter, 'i')) < 0) { | |
$(this).hide(); | |
} else { | |
$(this).show(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment