Get all URLs that match a pattern using jQuery


Source Code:

<script>
$(document).ready(function() {
	var pattern = /^\/string/;
	jQuery("a").each(function () {
		var href = jQuery(this).attr("href");
		if (href != undefined && href.match(pattern)) {
			console.log(href);
		}
	})
});
</script>

Buy us coffee

Reviews and Comments