简体   繁体   English

当元素被推送到新行时触发jQuery事件

[英]Fire a jQuery event when element gets pushed to new line

How can I fire a jquery event if the element in view gets pushed to a new line? 如果视图中的元素被推到新行,该如何触发jquery事件? I'd like to hide the nav items and also run some other javascript when this happens. 发生这种情况时,我想隐藏导航项并运行其他JavaScript。 Any suggestions on how to do this? 有关如何执行此操作的任何建议?

In a large view this is what my nav looks like: 从总体上看,这是我的导航看起来的样子:

大视图导航

This is what happens when I reduce my screen width. 当我减小屏幕宽度时会发生这种情况。 When this happens I want to fire events on those elements. 当发生这种情况时,我想在这些元素上触发事件。 How do I do this? 我该怎么做呢?

宽度更短的导航

If the view get's pushed down, it's based on the width of the container. 如果将视图下推,则基于容器的宽度。

Try using .resize() to keep track of the width & call the relevant functions when the width get's lower. 尝试使用.resize()跟踪宽度,并在宽度变小时调用相关函数。

$(window).resize(function() {

  // if the navigation DIV's width is smaller than xyz, do this ...

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM