Html string replace a span's class doesn't work in IE?
- by SeanJA
Someone tried to recreate smarty in js:
// actually from a template file, not hardcoded in the javascript
html = '<span class="{test}">yay</span>';
html = change(html, 'test', 'foo bar');
function change(html, key, value){
html = html.replace('{'+key+'}',value);
html = html.replace('%7B'+key+'%7D',value);
return html;
}
element.innerHTML = html;
In FF this works fine (as expected):
yay
In IE 7/8 and probably 6... it gives me this:
<span class="foo" bar="">yay</span>
Why does it create the extra attribute instead of doing what I expected it to do?