I have the following script:
$(".balkenclosed").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
I try to add a .replace function like this:
var replace = new Map([
/ [^a-zA-Z0-9\s]/ig, "", $id
]),
id = a;
replace.forEach(function(value, key){
id = id.replace(key, value);
});
It should replace invalid characters in the id of divs like this one:
<div class="balken"><div class="balkenopen"><a id="2our$ / team/2$"
style="text-decoration:none; color:black;" href="#2our$ / team/2$">
our team</a></div></div>
The result in this case should be id:"our_team" and href:"our_team"
My approach doesn't work and I feel like I'm completely wrong. I would really appreciate any hint into the right direction