JavaScript Clicking the screen to close an off canvas menu

as suggested by Matt U, you need to call closeNav on click on your main element by adding this in the html :

...
<div id="main" onclick="closeNav()">
...

But you also need to stop the click to propagate (event bubbling) because if not, when you try to open the menu by clicking the button, the click bubbles to the main div and immediately closes the menu...

so you need to add these lines to your javascript

document.getElementById("button")
  .addEventListener("click", event => {
    event.stopPropagation();
  }
)

and an ID to the button

 <span id="button" ...

here is a working example https://codepen.io/gui3/pen/mddogVj?editors=1010

Answer:1

I have AWS Cognito installed for my Angular application, and I am trying to hook in the s3.putObject some how into the ng-file-upload Upload service. I want to use ng-file-upload's Upload.upload() ...

I have AWS Cognito installed for my Angular application, and I am trying to hook in the s3.putObject some how into the ng-file-upload Upload service. I want to use ng-file-upload's Upload.upload() ...

  1. upload file using ajax
  2. upload file using retrofit android example
  3. upload file using javascript
  4. upload file using postman
  5. upload file using jquery
  6. upload file using ajax in php example
  7. upload file using php
  8. upload file using curl
  9. upload file using ajax php
  10. upload file using json
  11. upload file using python script
  12. upload file using ssh
  13. upload file using selenium
  14. upload file using ajax jquery
  15. upload file using putty
  16. upload file using curl command line
  17. upload file using httpwebrequest c#
  18. upload file using volley android
  19. upload file using web api c#
  20. upload file using javascript ajax

I want to know if it is more correct to use innerHTML: function createModal(){ modal = document.createElement('div'); modal.id = "modal"; modal.className = "modal"; modal.innerHTML = "<...

I want to know if it is more correct to use innerHTML: function createModal(){ modal = document.createElement('div'); modal.id = "modal"; modal.className = "modal"; modal.innerHTML = "<...

  1. append getelementbyid innerhtml
  2. element append innerhtml
  3. jquery append element innerhtml

I have a working graph which displays some nodes & their attributes. Then I get a JSON with different data, where some nodes may already exist on my graph. How to combine both data sources, to ...

I have a working graph which displays some nodes & their attributes. Then I get a JSON with different data, where some nodes may already exist on my graph. How to combine both data sources, to ...

I wrote a code, that make the button not disabled when you check at least one checkbox with class "sum". I want to change the code, so I have to classes for and you can check only one checkbox (or ...

I wrote a code, that make the button not disabled when you check at least one checkbox with class "sum". I want to change the code, so I have to classes for and you can check only one checkbox (or ...

  1. javascript disabled button still clickable
  2. javascript disabled button onclick
  3. javascript disabled button
  4. javascript disabled button by class
  5. javascript disabled button not working
  6. javascript disabled button color
  7. javascript disabled button css
  8. javascript disabled button html
  9. javascript button disabled enabled
  10. javascript button disabled attribute
  11. javascript button.disabled false not working
  12. javascript button disabled true
  13. javascript button disabled property
  14. javascript button disabled false
  15. javascript button disabled not working in chrome
  16. javascript button disabled attr
  17. javascript set disabled button
  18. javascript remove disabled button
  19. javascript toggle disabled button
  20. javascript disabled radio button