How to remove an iframe with JavaScript?

Sometimes, we want to remove an iframe with JavaScript.

In this article, we’ll look at how to remove an iframe with JavaScript.

How to remove an iframe with JavaScript?

To remove an iframe with JavaScript, we can use the remove method.

For instance, we write:

<iframe>

</iframe>

to add an iframe.

Then we write:

const iframe = document.querySelector('iframe')
iframe.remove()

to select the iframe with querySelector.

And then we call remove to remove it.

Conclusion

To remove an iframe with JavaScript, we can use the remove method.