[嗨,我正在尝试执行if语句,以查看值是否在数组中完全匹配。然后,我希望它的兄弟元素显示确切匹配的html。有人可以帮忙吗!我将TWIG用于高级自定义字段Wordpress插件的HTML。 Image of all the locations that I want to say only once with the number of times they are mentioned.这是用于过滤器功能的。最终希望使用https://codepen.io/luciopaiva/pen/YXYGYE?editors=101之类的带有位置标签的下拉菜单。
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>
[嗨,我正在尝试执行if语句,以查看值是否在数组中完全匹配。然后,我希望它的兄弟元素显示确切匹配的html。有人可以帮忙吗!我用...