user3179658
user3179658

Reputation: 103

Close a popup modal

I have been attempting to get greasemonkey to close a modal by clicking the "x" button. Here is the code for the page.

<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" onClick="window.location.reload()">x</button>

I've tried using document.querySelector('.close').click() but to no avail. Where am I going wrong here?

The page in question is running javascript and ajax.

Upvotes: 1

Views: 306

Answers (2)

mohamedrias
mohamedrias

Reputation: 18566

The code looks like bootstrap modal, so look for the main container ID or class name and use the following code.

$('#modalID').modal('hide');

Upvotes: 1

Rob M.
Rob M.

Reputation: 36511

Why don't you just add the hide class to the modal? That's all that clicking it is going to do.

Upvotes: 0

Related Questions