Categories
JavaScript Answers

How to remove an iframe with JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *