Response title
This is preview!
<!--This is where I filter the ListBox (select) >> (option) elements via keystrokes -->
<!--Via jQuery on my Listbox control I add a css class so I can work with it here - class ".srcItem" -->
<script type="text/javascript">
$(document).ready(
function () {
var elemSrc = document.getElementById("<%=srcBox.ClientID%>");
$(elemSrc).find("option").addClass("srcItem");
}
);
</script>
<script type="text/javascript">
$(document).ready(
function () {
var $users = $('.srcItem');
$('#usrSearch').keyup(function () {
$users.show(); //THis is regular jQuery that works only in Chrome
return;
}
var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
//Below is regular jQuery that works only in Chrome
$users.show().filter(function () {
var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
return !~text.indexOf(val);
}).hide();
});
}
);
</script>
<option> wrapped with <span> is INVALD HTML. The direct parent of <option> MUST be <select>."I wanna wrap the content with <span> and then hide it."
© 2013 jQuery Foundation
Sponsored by and others.