简体   繁体   中英

Change HTML tags using javascript

I'm having tags like: <img>01.jpg</img><img>02.jpg</img> And i want to create correct HTML image tags. How ca I do this with javascript?

That look really good. How can I iterate over several divs with id="demo"?

First, take the Div Element. like this.

 <div id="demo">
 </div>

Then add the below javascript code in the script tag.

<script>
    var divElement = document.getElementById("demo");
    var img = document.createElement('img');
    img.src = "https://fakeimg.pl/440x320/282828/eae0d0/?retina=1";
    divElement.appendChild(img);
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM