I am creating an image object in JavaScript as
myImg = document.createElement('<img id=preview_image src="src/myImage.jpg" align="baseline" width="50%" height="80%"/>');
The image HTML will be obtained from database as in the given form. Now, how can I get the height and width with the units (i.e. 50% for width in this case)?
document.createElement(). You can only pass the element name.IMGelement and then parsing the HTML string to populate the respectiveIMGattributes, is there any better way?div, setting it'sinnerHTMLand then usingchildNodeswhich will be the HTML content of the string.