I would like to change a part of the url inside of the src attribute. This would be called with a click function. This could change the language of the like button without refreshing the page and when another language was selected previously.
This works well, but since there are multiple languages, it only works once; when the base "state" is hu_HU (Hungarian):
$('.fb-like').attr('src', function(i, src) {
return src.replace("hu_HU","ro_RO");
});
I changed the code to accomplish the goal according to the solution in this question: JQuery: how to replace all between certain characters? but without any success:
$('.fb-like').attr('src', function(i, src) {
return src.replace(/locale\=.+?\&/g,"locale="+ro_RO+"&");
});
What am I missing? Any help would be appreciated! Thank you in advance!
Here is the fiddle: http://jsfiddle.net/iorgu/a0aptp3g/2/