You need to avoid = with \\= .
param = param.replace(/=/g, '\\\\=');
But there are other special characters that you also need to hide in the jQuery selector.
function escape(param) { return param.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g,'\\\\$1'); }
You can also use the .filter method.
$('a').filter(function() { return $(this).attr('href').indexOf(param) !== -1; })
source share