JSFiddle - React, Tailwind, and code Playground

by Rajan Paneru

HTML

<div class="balken">
  <div class="balkenopen">
    <a id="2our$ / team/2$" style="text-decoration:none; color:black;" href="#2our$ / team/2$">
      our team
    </a>
    <a id="2ourgatteam/2$" style="text-decoration:none; color:black;" href="#2our$ /    team/2$">
      our team
    </a>
  </div>
</div>

<div class="show_dump">
<h3>Changed Html
</h3>
<pre>
  
</pre>
</div>

CSS

pre{
  background-color: #ddd;
}

JavaScript

$('a').each(function() {
  var self = $(this);
  var id = self.attr('id');
  var href = self.attr('href');
  if (id)
    self.attr('id', stripEverything(id, '_'));
  if (href)
    self.attr('href', '#'+stripEverything(href, '_'));
});

function stripEverything(string, replaceSpaceWith) {
  return string.replace(/[^a-zA-Z ]+/g, '').split(' ').filter(function(e) {
    return e
  }).join(replaceSpaceWith);
}
$('.show_dump pre').text($('.balken').html());