I am trying to get the following bit of code to work, but I seem to be missing something
var dom = document.URL;
$("a[href=dom]").addClass("active");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li>
<a href="http://example.com">
<i class="fa fa-home"></i>
Home
</a>
</li>
<li>
<a href="http://example.com/about">
<i class="fa fa-info"></i>
About
</a>
</li>
What's supposed to happen is when at http://example.com the class active will be added to the first a element, if at http://example.com/about then the second a will get the class.
I used javascript's alert to make sure I was getting the right URL, and it is as it shows in href, however what I have above doesn't work. I have tried the Javascript responses given here but they don't work either.
$('a[href="' + dom + '"]').addClass("active");window.location.hrefinstead, and remove the class from all of those anchors prior to setting the class, otherwise they'll all have it