Last active
June 24, 2020 11:21
-
-
Save SuryawanshiPrajakta/70a4e5bb022e5efeff70af66e670e134 to your computer and use it in GitHub Desktop.
Close Off-Canvas on click of a button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Add a custom class to the Button on which you want to close the off-canvas. | |
Refer - https://cl.ly/f61014b8265b | |
2. Paste below code in your active Themes Functions.php file - | |
function offcanvas_custom_script() { | |
?> | |
<script type="text/javascript"> | |
jQuery(function($) { | |
$( '.custom-close-offcanvas' ).click( function () { | |
var $canvas = $( '.uael-offcanvas-show' ).attr( 'id' ); | |
$canvas_id = $canvas.substring( $canvas.indexOf('-') + 1 ); | |
OffCanvas._close( $canvas_id ); | |
}); | |
}); | |
</script> | |
<?php | |
} | |
add_action( 'wp_footer', 'offcanvas_custom_script' ); | |
Note - In the above code the "custom-close-offcanvas" will be replaced by the custom class you will add to the button. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment