/ Published in: JavaScript
Why doesn't this work?
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var str="foobar"; var val="foo"; var search='/'+val+'/i'; alert(str.replace(search, '<strong>'+val+'</strong>')); // it alerts "foobar" and not "<strong>foo</strong>bar"