Reputation: 370
In mobile screen, I want to delete
div from the third one, but 15 was deleted not 27, I don't know why anyone can resolve this?
if (jQuery(window).width() < 700) {
for (var i = 3; i < 31; i++) {
jQuery(".status-publish").eq(i).remove();
// alert(i);
}
}
Upvotes: 1
Views: 52
Reputation: 337570
You don't need JS for this. You can use CSS to hide elements along with a media query to detect the screen size:
@media only screen and (max-width: 700px) {
.status-publish:nth-child(n+3):nth-child(-n+31) {
display: none;
}
}
Upvotes: 1
Reputation: 72299
Use :gt()
if (jQuery(window).width() < 700) {
jQuery(".status-publish:gt(2)").remove();
}
Note:- you need to call the is code both on document.ready
as well as window.resize
too.
Reference:-
Upvotes: 4