I am designing a modal and I am having issues with controlling click events. Let me first show a framework of my HTML code so I can better explain the problem
- <div class='modal-wrapper'>
- <div class='modal-whole'>
- <div class='modal-header'>
- <h1></h1>
- </div>
- <div class='modal-body'>
- <p></p>
- </div>
- <div class='modal-footer'>
- <a href="#">Close</a>
- </div>
- </div>
- </div>
The class modal-wrapper will be expanded to fill 100% of the screen and will be top-most over all other elements outside of this framework. The modal-whole class will contain data to display to the user on a much smaller scale. Right now I have jQuery code as follows:
- $(".modal-wrapper").click(function() {
- $(this).fadeOut(500);
- });
So this WILL fade out when you click the backdrop, however, it will also fadeout when you click within the other elements that are on top of the backdrop. This is an undesired effect and is what I want to counter. Any suggestions?