Onclick to close a modal without Reload

Asked

Viewed 605 times

1

This button closes a modal, but needs to be without causing a Reload. There are ways?

<button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="javascript:window.location.reload()"><span aria-hidden="true">×</span>
    </button> 
  • 3

    All you have to do is remove the function window.location.Reload in the onlick button.

  • Place javascript:void(0)

1 answer

0


The problem is that on this button of yours:

<button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="javascript:window.location.reload()"><span aria-hidden="true">×</span></button> 

the code:

onclick="javascript:window.location.reload()"

causes the page to be reloaded, you can take this event from onclick or else put to return void.

<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> 

onclick="javascript:void(0)"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.