i want to take out two result when condition is true so i made small function for it but only first result is appearing when condition is true. i set height and width attribute because when src is blank ie display image frame and if i leave height and width attribute blank ie taking height and width 1 px.
$(function () {
if ($('img.offerProduct').attr('src') == false) {
$('.offerProduct').removeClass('offerProduct');
$('.offerProduct').attr({width:'0', height:'0'})
}
}
)
<body>
<img src="" width="60" height="60" class="offerProduct" />
</body>
The
attr()method only gets the attribute of the first element in the matched set. To process all images with the classofferProduct, you should use theeach()method: