Anyone can please help me why it returning an empty array. and thanks in advance. you can check code on http://newseinstein.com/Rwork/index.php/Listing.
Code sample :
function search(){
var pettype = [];
$(".pettype :checked").each(function(){
alert($(this).val());
pettype.push($(this).val());
})
alert(pettype);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" name="type[]" class="pettype" value="Lost" onclick="search();">
<input type="checkbox" name="type[]" class="pettype" value="Found" onclick="search();">