0

I'm new to JS and I'm playing a bit around Here is what I have at the moment

jQuery("td.ninja_column_0.ninja_clmn_nm_film.footable-first-visible a").each(function(){
var newUrl = jQuery(this).attr('href').split(' ').join('_');
jQuery(this).attr("href", newUrl);
});

So here every space in my URL gets replaced with an _ No I also have äöü or ß that needs to be replaced by something. I could simply copy the code above x time under the other, that works, but I think there is a better way and I think someone here can help me.

By the way I first used

var newUrl = jQuery(this).attr('href').replace(' ', '_');

But this just replaced once my space

Already thanks for any ideas :)

  • Do you need it in jQuery or Javascript? – aca Jul 05 '22 at 09:25
  • Do you mean [How to replace all occurrences of a string in JavaScript](https://stackoverflow.com/q/1144783)? – VLAZ Jul 05 '22 at 09:26
  • @aca what does jQuery provide for string replacement? – VLAZ Jul 05 '22 at 09:26
  • @VLAZ To be honest I have no idea. I've just saw the question asking about JS, and the code is written using jQuery (which I'm really bad at). – aca Jul 05 '22 at 09:28
  • 1
    @aca jQuery primarily has tools for manipulating the DOM. There is some collection handling but it's been basically superseded by JS. It also allows for easier management of AJAX. It's not some alternative form of JS. It doesn't replace or add on much more. – VLAZ Jul 05 '22 at 09:33

0 Answers0