jquery loop and compare values
Posted
by
lgt
on Stack Overflow
See other posts from Stack Overflow
or by lgt
Published on 2012-06-19T09:11:31Z
Indexed on
2012/06/19
9:16 UTC
Read the original article
Hit count: 150
jQuery
Is it possible to use jqueries each loop in this form to dissolve hyperlinks?
$(document).ready(function() {
var toExclude =['http://www.google.com', 'http://example'];
$.each(toExclude, function(key, value) {
$("a[href='+value+']").replaceWith(function(){
var url=value;
var matches = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
var domain = matches && matches[1];
return domain;
});
});
});
© Stack Overflow or respective owner