Let's say hypothetically I want to replace all 'a' in a string with 'b'
'abc' -> 'bbc'
I want to run this on various strings:
var str1= 'abc'
var str2= 'adf'
var str3= 'abvxvb'
var str4= 'ae54'
I'm trying to write a jquery plugin that does this.
So I can do str1.a_to_b();
and get the desired result. (Actually having the syntax in another form is fine too).
There's something wrong with my attempted syntax:
jQuery.fn.a_to_b = function(expr) {
return this.each(function() {
this = this
.replace(/a/ig, "b");
});
};
Thanks.