Hi I am trying to do an if statement to see if values have an exact match in an array. Then I want it the sibling element to show the html of what the exact match is. Can someone help please! I use TWIG for the HTML from Advanced Custom Fields Wordpress plugin. Image of all the locations that I want to say only once with the number of times they are mentioned. This is for a filter functionality. Eventually want to have a dropdown like https://codepen.io/luciopaiva/pen/YXYGYE?editors=101 with a locations tab.
Jquery
//exact match
$(".filter-dropdown .course-location").each(function(i,e) {
myDivObj = $(this).val() == $(this).val();
if ($(this).val() == $(this).val()) {
console.log()
$(this).parent('.filter-dropdown').siblings('.class-location').children('h4').html(myDivObj);
$(this).parent('.filter-dropdown').siblings('.class-location').children('span').html($(".course-location").length);
}
else {
console.log('unknown');
}
});
HTML
<div class="filter" id="course-location">
<div class="upper-filter"><h3>Locations</h3><i class="fas fa-angle-down"></i></div>
{% for category in bloc.training_course_list_compact.course_categories %}
{% for locationcourse in category.get_field('courses') %}
{% for location in locationcourse.get_field('dates') %}
<div class="filter-dropdown">
<div class="course-location" value="{{ location.location }}"></div>
</div>
{% endfor %}
{% endfor %}
{% endfor %}
<div class="class-location"><h4></h4><p></p><span></span></div>
</div>