$(document).ready(function() {
var pic = $(".pic");

// need to remove these in of case img-element has set width and height
$(".pic").each(function() {
    var $this = $(this);
    $this.css({width: 'auto', height: 'auto'});

    var pic_real_width = $this.width();
    var pic_real_height = $this.height();
    if(pic_real_width<100){
    $(".pic").css("display","none");
    }
    });

 });

我需要这个来检查.PIC类的所有图像的高度(它已经这样做了),然后添加一个显示:无那些谁具有一定的规模。 (例如,如果一个img已根据100px的宽度应该不被显示)

有帮助吗?

解决方案

此应达到目的:

$(document).ready(function() {
    // need to remove these in of case img-element has set width and height
    $(".pic").each(function() {
        var $this = $(this);
        $this.css({width: 'auto', height: 'auto'});

        var pic_real_width = $this.width();
        var pic_real_height = $this.height();
        if(pic_real_width<100){
            $this.css("display","none");
        }
    });
 });

在洁具再次引用集合而不是一个具体的元素

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top