I would like to hide element with class="wp-caption-text" if image size is <= 300
<div id="attachment_65209" style="width: 230px">
<a href="#" rel="lightbox[70848]">
<img src="/LCP-2015-05-31-s1.jpg" width="220" height="269">
</a>
<p class="wp-caption-text">Sen. Charles Schwertner • District 5</p>
</div>
So far i tried using the following but no luck:
<script>
jQuery(window).on('resize load', function () {
jQuery('.wp-caption-text').each(function(i, el){
var section = jQuery('.wp-caption-text');
var width = section.width();
if (width <= 300) {
section.attr('class', 'caption-none');
}
})
})
</script>
<style>.caption-none{display:none;}</style>
Any suggesstions?
Try this: