[英]Window trigger function doesn't work in Jquery
I have a made a sidebar with a toggle function in jquery. 我在jquery中使用了切换功能制作了侧边栏。 This is my function:
这是我的功能:
function toggle() {
var $btn = $(".sidebarToggle");
var $budget = $(".budget");
if ($budget.hasClass("sidebarHidden")) {
$btn.find("i").removeClass("fa-caret-right").addClass("fa-caret-left");
$budget.removeClass("sidebarHidden");
} else {
$btn.find("i").removeClass("fa-caret-left").addClass("fa-caret-right");
$budget.addClass("sidebarHidden");
}
$(window).trigger('resize');
}
And this is my HTML5 code: 这是我的HTML5代码:
<div class="sidebar sidebar-hastopnav autoscroll">
<div class="sidebarToggle" ng-click="vm.toggle()"><i class="fa fa fa-caret-left"></i></div>
The problem is when I click on the class it wont fire the $(window).trigger('resize');
问题是,当我单击该类时,它不会触发
$(window).trigger('resize');
function and it doesn't resize. 功能,并且不会调整大小。 I already check the other stackoverflow post like: jQuery resize event not firing
我已经检查了其他stackoverflow帖子,如: jQuery resize event not fireing
And 和
$(window).resize() not working $(窗口).resize()不起作用
What am I doing wrong? 我究竟做错了什么?
Kind regards. 亲切的问候。
Update: 更新:
You can try alternative solutions provided in this Stackoverflow blog post on - Window Resize . 您可以尝试此Stackoverflow博客文章“ 窗口调整大小”中提供的替代解决方案。
Hope this helps you. 希望这对您有所帮助。 Thanks.
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.