js 比较网址与a链接


  $(document).ready(function(){
    let aray = Array.prototype.slice.call(document.querySelectorAll('a'));
     console.log(aray);  
     aray.forEach(element => {
        if(element.href === window.location.href){
            let aa = [element];
         [element][0].className = 'on';
        }
    });
  })
 
(function ($) {
    $.getUrlParam = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
    })(jQuery);
    $(function () {
    let hrefLength = window.location.href.length;
    const newstring = window.location.href.substring(hrefLength-2, hrefLength)

})
原文地址:https://www.cnblogs.com/111wdh/p/14246953.html