English 中文(简体)
j 质量——职能必须重整不一贯工作的活动
原标题:jQuery - function bound to resize event not working consistently

我有几部法典,以点击gle菜。 我只想操作该代码,如果窗户在768页以下,那么我就在一份计算窗户的报表中加以总结。 我将这一职能限制在网页转播活动和网页上。 它有些时间,但不是其他时间。 几次恢复成果小组的工作,看看我的含义......

http://jsfiddle.net/agileapricot/LyUzr/

最佳回答

不是关键问题,而是:j Query ("#nav-btn a.togglemenu”>j Query("#nav a.togglemenu”)

页: 1

jQuery(window).bind("resize", aaMenus);

......行使职能,并增加new 点击手, 每当窗重新大小。 如果点击手被加起来的次数甚至多,那么你会同时重新行乞,没有明显结果。 即使增加了奇数倍,你还是继续把 to头拖到数百次,造成大量拖延。

All you need to do is take that click event handler out of your function: http://jsfiddle.net/mblase75/LyUzr/10/

function aaMenus() {
    if (jQuery(window).width() > 768) { // iPad and Desktop
        /* Dropdown Menu */
        jQuery("ul#menu").addClass("dropdown").removeClass("toggle").show();
        jQuery("a.togglemenu").hide();

        //.. Drop down function will go here later
    } else { // Mobiles
        /* Toggle menu */
        jQuery("ul#menu").addClass("toggle").removeClass("dropdown").hide();
        jQuery("a.togglemenu").show();
    }
}

jQuery(window).bind("resize", aaMenus);

jQuery(document).ready(function() {
    jQuery("#nav a.togglemenu").click(function() {
        jQuery("ul.toggle").toggle();
    });
    aaMenus();
});
问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...