jquery filter with two different number values
I wrote this script that filters through a table which contains numbers
treated as strings. I converted the string to a number using parseInt().
See code below. I was then asked to also apply this to another cell which
contains a string with either '1.00' or '0.00' and has a class called
goal. I know I can duplicate the code below and change the parse to look
for number == 1, but I am looking for a more efficient way to manage it.
<script type="text/javascript">
$(document).ready(function () {
$('td.completedPercent').filter(function (index) {
return parseInt(this.innerHTML, 10) >= 90;
}).css({ 'color': '#FFF', 'background-color': '#336633' });
});
</script>
No comments:
Post a Comment