I am trying to get the value of
<?php
$i = 0;
foreach ($categories as $key => $category) {
?>
<div class="col-6 col-md-4 col-lg-2 text-center category">
<li class="main-li" id="<?php if ($i == 0) {
$i = 1;
echo 'active-nav';
} ?>" value="<?php echo $key ?>">
<?php echo $category ?>
</li>
</div>
<?php } ?>
This is my jquery
$(".category").click(() => {
var category_id = $('li #active-nav').attr('value');
alert(category_id);
});
Anybody can help be get the value when i click each category div
thisLIkevar category_id = $(this).attr('value');