In this article, we are going to discuss how to trigger the window resize event using jQuery. For this purpose, we will use the following library functions provided by jQuery.
- $(<element>).resize(): This method is used to listen to resize events. The method can take callback functions as parameters, which will be executed once the resize event is encountered.
jQuery CDN link:
<script src=”https://code.jquery.com/jquery-3.5.1.min.js” integrity=”sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=” crossorigin=”anonymous”></script>
Here, the resize event will be triggered on a button for easier understandability.
Output of the given Code Snippet: