The issue to solve is to inactivate the months that are not in the list. I have a list of posts that populates the DOM and an unordered list aside. I only want the user to see the months highlighted where there is a matching HTML row.
Here is what my html looks like:
<div data-filter="February">Feb</div>
<div data-filter="April">Apr</div>
Here is my unordered list:
<ul>
<li>January</li>
<li>February</li>
<li>March</li>
<li>April</li>
<li>May</li>
<li>June</li>
<li>July</li>
<li>August</li>
<li>September</li>
<li>October</li>
<li>November</li>
<li>December</li>
</ul>
Can someone please show me the logic to only highlight the months of February and April?
Thanks!
2
Answers
You can do the following:
font-weight
property to bold if the substring matches the div text content.Check following code:
instead of using
forEach
you can use the jquery:contains
which is more faster.jQuery version:
Reference: jQuery selector for an element that directly contains text?