var searchp = $('body'),
searchval = searchp.html(),
name = ['Abraham Lincoln', 'George Washington'];
cname = name.toLowerCase().replace(/ /g, ''),
restr = searchval.split(name).join('<a href="#" data-name="'+cname+'">'+name+'</a>');
searchp.html( replacestr );
I need some help with a litte replace function. It works fine if I use name= 'string name', but I can't get it to work with arrays. Hopefully you can help me.
;after the Array which makescnameandrestrglobal variables. I prefer to use leading commas on each line (below thevar) instead of trailing commas to make it very clear that all the commas are present.