[英]Jquery or Javascript: How to find all html elements which has image more than 500px and less than 2000px?
I want to find all html elements with jquery or javascript which has image more than 500px and less than 2000px. 我想使用图像大于500px且小于2000px的jquery或javascript查找所有html元素。 Here is my code.
这是我的代码。
$("*").each(function() {
var image = jQuery(this);
if ((image.attr("width") >= 512) && (image.attr("width") <= 2048)){
//do something
}
}
But with this code I can only find img tag and also which we give width static. 但是,使用此代码,我只能找到img标签,而且我们也可以给它定宽度。 Ex: working not working And also I can't find div elements or something.
例如:工作不正常而且我也找不到div元素或其他东西。 I want to find all html elements which has image where we see width is more than 500px and 2000px.
我想找到所有具有图像的html元素,其中我们看到宽度大于500px和2000px。 For example:
<div class="back_img"></div> css: .back_img{background-image:url("img/img.png")}
I want to find this also. 例如:
<div class="back_img"></div> css: .back_img{background-image:url("img/img.png")}
我也想找到它。 Is there anybody who knows solution? 有谁知道解决方案吗?
Try: 尝试:
$("*").each(function() {
var image = jQuery(this);
if ((image.width() >= 512) && (image.width() <= 2048)){
//do something
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.