This is quite peculiar. Take a look at this rapid testing function:
function test_function(){
code = '<img src="http://www.myimage.com/img.jpg" alt="image" />';
alert(code);
document.getElementById('test').innerHTML = code;
alert(document.getElementById('test').innerHTML);
}
If you run the code above, the first alert will display />
, but the second alert will only show >
. It seems that when using .innerHTML
, the forward slash gets removed. Any suggestions on how to prevent this? I require the forward slash for validation purposes.