var html_str = '...some images and other markup...'; var temp = document.createElement( 'div' ); temp.innerHTML = html_str; var images = temp.getElementsByTagName( 'img' );
... then scroll through the images ...
for( var i = 0; i < images.length; i++ ) { images[ i ].className = "my_class"; }
What you really need to do can change how your loop works, but the above just adds a class, so this is a regular for
loop.
Note that at the moment you are dealing with DOM elements, not markup. These elements can be added directly to the DOM.
source share