stopPropagation not working as expected
Hello. I cannot get stopPropagation to stop the bubbling. I don't understand why; isn't this what it;s supposed to do? I am expecting that when I click on the "test" element that it will alert ('test clicked') and then stop ('prop failed') from being alerted.
- <div id="wrapper">
- <div id="content">
- <div id = "parent">
- <div id="test" class="button">Top Button</div>
- </div>
- </div>
- </div>
- $('#parent').click(function () {
- alert('prop failed');
- });
-
-
- $('#content').on('click', '.button', function (e) {
- e.stopPropagation();
- alert('test clicked');
-
- });