检查具有一定宽度的div [英] Check for div's with a certain width

查看:135
本文介绍了检查具有一定宽度的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆div,我现在设置为动画。然而,我想要一种方式,如果他们已经动画(他们的宽度将从100px更改为300px例如),他们不会重新生活,当我再次点击他们。我是javascript& jquery所以我不确定如何检查div元素的宽度放置在if语句中。如果我需要发布代码,我可以,如果要求。感谢

I have a bunch of div's that I have set to animate at the moment. However I am wanting a way that if they've been animated (Their width would have changed from 100px to 300px for example) they won't reanimate when I click on them again. I'm new to javascript & jquery so I'm unsure how to check the width of a div element to place in an if statement. If I need to post the code I can if requested. Thanks

推荐答案

像这样:

$('selector')
    .filter(function() { return $(this).width() < 300; })
    .animate(...);

这篇关于检查具有一定宽度的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆