how can I make the data-kategori
and data-secim
attributes of the input: checked element on a page like this:
url=/?kategori=1-2-3&bolum=4
I got the list of categories but I can not match the data-selection
of this categori list
$(function() {
$("input").click(function() {
var kategori = [];
var a = "";
$("input:checked[data-kategori]").each(
function() {
a = $(this).attr("data-kategori"),
b = $.inArray(a, kategori)
if (b == -1) {
kategori.push(a);
}
});
console.log(kategori);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<p><input type="checkbox" data-kategori="kategori" data-secim="1" id="scrum" /> <label for="scrum">scrum</label> </p>
<p><input type="checkbox" data-kategori="kategori" data-secim="2" id="crystal" /><label for="crystal">kristal</label> </p>
<p><input type="checkbox" data-kategori="kategori" data-secim="3" id="xp" /><label for="xp">xp</label> </p>
<p><input type="checkbox" data-kategori="bolum" data-secim="4" id="ayna" /><label for="win">win</label> </p>