jQuery: Finding link best matching to current URL

jQuery: Finding link best matching to current URL

HTML

<ul class="ui-ajax-tab">
        <li><a href="http://www.abc/HTMLPage14.htm">Test 1 (/HTMLPage14.htm)</a></li>
        <li><a href="/HTMLPage15.htm">Test 2 (/HTMLPage15.htm)</a></li>
        <li><a href="/HTMLPage16.htm">Test 3 (/HTMLPage16.htm)</a></li>
        <li><a href="/HTMLPage17.htm">Test 4 (/HTMLPage17.htm)</a></li>        
    </ul>

CSS

.ui-ajax-tab
        {
            list-style: none;
        }
        
        a.currentPage
        {
            color: Red;
            background-color: Yellow;
        }

JavaScript

$(document).ready(function () {
            var windowLocationPathname = "/HTMLPage14.htm";  // For testing purpose.

            //Or

            //var windowLocationPathname = window.location.pathname;

            $('ul.ui-ajax-tab').find('a[href^="' + windowLocationPathname + '"]').addClass('currentPage');
        });