I am using IE 8 and trying to set the element identifier attribute. Then I add this element to the parent element and check its innerHTML. The problem I see is that there are no double quotes in the id attribute. At first, I thought this could be the reason that I was using the setAttribute property, and that could be a bug in IE 8, so I used jQuery to set attribute values, but the problem was still there. Here is my code ...
var imgId="my" + val_imgarea + "img"; var img=document.createElement('img'); $(img).attr("Id",imgId); img.setAttribute('src',name); img.setAttribute('style',"width:100%;height:100%"); $(img).click(function(){clic(imgId);}); var input=document.createElement('input'); input.setAttribute('type','text'); input.setAttribute('id',name); input.setAttribute('style',"display:none"); var parent=document.getElementById(newArea); parent.appendChild(img); parent.appendChild(input); alert($("#"+newArea).html());
output
<IMG id=my21img style="width:100%;height:100%" src="a/img.jpg" />
I need double quotes with id cauze. Then I write this html to a file, and then some other applications read it and cause problems with missing quotes.
source share