javascript - How to remove class on resize? -
Then, I have a hamburger menu button, when clicked,
but also changes 3 lines for an X (with a JQuery toggle that activates a secondary set of CSS variables). When it is clicked again, & lt; Ul & gt;
disappears and X changes the original set of changes (3 lines), I also have set that if the page is resized, when the list is open, the list is closed And I'm trying to make it so that the resize button has the original set of CSS variables (i.e. line).
Here is JS and JQ:
& lt; Script & gt; Window.onload = function () {document.querySelector ('# menu-icon'). AddEventListener ('click', function () {this.classList.toggle ('active');}); $ (Window) .on ('resize', function () {$ ("# menu-mobile"). Hide ();}); }; & Lt; / Script & gt; & Lt; Script src = "script / jquery.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; $ ('# Menu-icon'). Click (function () {$ ("# menu-mobile") Slide Toggle ("Medium");}); & Lt; / Script & gt;
This is CSS:
# menu-icon {margin-top: 27px; Margin-right: 4px; Padding: 0; Width: 40px; Height: 40px; Cursor: indicator; Text align: center; } # Menu-icon & gt; Period {display: block; Margin-top: 6px; Border-top: 3px solid # 666; Status: Relative; -Wbkit-Infection: all 0.2 cubic-beijier (.15,1.43, .46,1.25); Infections: all 0.2 cube-beijier (.15,1.43, .46,1.25); Margin: Official war; } # Menu-icon: hover & gt; Duration {boundary-top: 3px solid # 333; } # Menu- cyan.active & gt; .ln-one {-webkit-transform-origin: top left; -WebKit-Converting: To rotate (45 degrees); -MMS-change-origin: top left; -MMS-transform: rotate (45 degrees); Contextual Origin: Top Left; Consequently: rotate (45 degrees); } # Menu- cyan.active & gt; .ln-two {border color: transparent; } # Menu- cyan.active & gt; .ln-three {-webkit-transform-origin: left bottom; -WebKit-Transform: Rotate (-45 degrees) translate Y (6px) translateX (-6px); -MMS-transform-origin: left bottom; -mms-conversion: rotate (-45 degrees) translate Y (6px) translateX (-6px); Change-Origin: Left Down; Conversion: Rotate (-45deg) Translation Y (6px) translateX (-6px); }
Thanks in advance for any help.
simply
jQuery
$ (window) .on ('resize', function) $ ("# menu-mobile"). Hide (); $ ('# Menu-icon') RemoveClass ('active');}); .on ('resize', function () {$} via
or classList API
$ (window) ("# Menu-mobile") Hide (); document.query selector ('# menu-icon') ClassList.remove ('active');});
In addition to this, your jquery.js
is followed by all other before
Comments
Post a Comment