JQuery高度条件
$(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 类的所有图像的高度(它已经这样做了),然后为具有特定尺寸的图像添加 display:none 。 (例如,如果 img 的宽度低于 100px,则不应显示)
$(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");
}
});
});
I need this to check for the height of all images of the .pic class (it already does this) and then add a display:none to those who have a certain size. (e.g. if an img has under 100px width it should not be displayed)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可以解决问题:
您再次引用集合而不是具体元素
This should do the trick:
you ware again referencing the collection and not a concrete element