Hi... so I'm new to jQuery. I'm using it to dynamically filter a
list... I'm wondering if this is the best/most efficient method to go
about doing it:
<html>
<head>
<title>jquery test</title>
<script type="text/javascript" src="js/jquery-1.2.3.min.js"></
script>
<script type="text/javascript">
$(document).ready(function() {
var arr = ['C+
+','D','HTML','CSS','C#','PHP','Python','XML','JavaScript','Photoshop'];
for(i=0; i<arr.length; ++i) {
$('#list').append('<li>'+arr[i]+'</li>');
}
$('[EMAIL PROTECTED]').keyup(function() {
$('#list').empty();
for(i=0; i<arr.length; ++i) {
if($
('[EMAIL PROTECTED]').attr('value')==undefined||
arr[i].toLowerCase().indexOf($
('[EMAIL PROTECTED]').attr('value').toLowerCase())!=-1)
{
$('#list').append('<li>'+arr[i]
+'</li>');
}
}
});
});
</script>
</head>
<body>
<ul id="list"></ul>
<input name='filter' id="filter"/>
</body>
</html>
See it in action: http://mechaflora.com/programming/filter
Any suggestions on how I can do this better would be appreciated :) Or
feel free to use the code for your own purposes if you think it's good.