The task is to generate a popup using jQuery. Popups are useful to splash important information to the visitors of a website.
Approach: A simple pop can be made by using toggle() method of jQuery which toggles between hide() and show() function of jQuery i.e. it checks the visibility of the selector used. The hide() method is run when the selector is visible and show() is run when the selector is not visible.
It displays the popup if the show popup button is clicked and hides the popup if the closed button is clicked.
The selector used for toggling is ” .content ” which contains the close button and popup’s body. Initially to hide the popupon page reload we have used the display: none property on the .content class in style tag.
Now when the user clicks on the show popup button the onclick event calls the togglePopup() which displays the popup and when the user clicks on the close button onclick event again calls the togglePopup() which hides the popup.
Please Login to comment...