I made a search bar to search an app and a checkbox to filter apps by platforms but when I write something on the search bar and click on a button of my checkbox, the search bar value is not taken into account and I have to rewrite something to update the research by platform. What should I add to take into account my search bar value when I click on a checkbox button? thanks
<script>
$(document).ready(function(){
$("#searchapp").on("keyup", function() {
var value = $(this).val().toLowerCase();
var platform = $('#checkbox input:checked').attr('name');
$("#table .anapp:contains('" + platform + "')").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
$("#ios").click(function(){
$(this).prop('checked', true)
$('#android').prop('checked', false)
$(".anapp").hide();
$(".anapp:contains('iOS')").show();
});
$("#android").click(function(){
$(this).prop('checked', true)
$('#ios').prop('checked', false)
$(".anapp").hide();
$(".anapp:contains('Android')").show();
});
});
</script>
Aucun commentaire:
Enregistrer un commentaire