bobyckocks
New Member
I have a string of text that has the value of the selected text. Id like to do a replace() of this text in a given div of text.so I know I can do that with the following:\[code\]myelement.replace(/foo/g, 'bar');\[/code\]However I need to do it with my string ie:\[code\]myelement.replace(/*mystring*/g, 'bar');\[/code\]So I tried:\[code\]mystring = '/'+mystring+'/g';myelement.replace(mystring, 'bar');\[/code\]Which didnt work, so i tried (which i knew wouldn't work):\[code\]myelement.replace(/+mystring+/g, 'bar');\[/code\]So how can i do this?I've coded something up for you guys in jsfiddle --> HELP ME PLEASE!