Js determines whether there is an img in a class.

<div class="imgpd">
123
456
789
...
<div>

check whether there is a tag in imgpd. If not, add a * >

.
Aug.27,2021

first add id

<div class="imgpd" id="imgpd">
123
456
789
...
<div>

then get the length of img

document.getElementById('imgpd').getElementByTagName('img').length

if the length is greater than 0, it means there is a picture, otherwise there is no picture


$('.imgpd').append(function(){
    if (!$(this).children().is('img')) {
        return '<img>';
    }
});
Menu