On a page with several urls I want to be able to remove the whitespace in the slug and replace it with a hyphen.
I can case where I have a single url, but I'm having trouble with multiple url case.
I assume the script must use each(function())
Based on the version I used for the single version I tried the following:
$(document).ready.(function() {
$('a.testlink').each(function() {
var Text = $(this);
Text = Text.toLowerCase();
Text = Text.replace(/[\s]+/g,'-');
$(this).attr("href", Text);
});
});
But the script fails completely having no effect on the url - it neither makes lower case nor replaces the whitespace.
How do I get the script to loop over each href and replace any spaces found in the slug.
I believe the line that says var Text = $(this);
should be var Text = $(this).attr("href");