How do I get the length of every image with 100px
or more of width
:
if( $('img').width( >= 100 ).length > 0 ){
[MORE CODE]
}
How do I get the length of every image with 100px
or more of width
:
if( $('img').width( >= 100 ).length > 0 ){
[MORE CODE]
}
You can use filter()
to achieve this:
$(window).load(function() {
var $imgs = $('img').filter(function() {
return $(this).width() >= 100;
});
// do something with $imgs...
});
Note that you should execute this under the window.load
event to ensure that the img
elements have loaded and therefore have a set width.
You can do this: