Xhakalaca Xhakalaca - 1 year ago 49
AngularJS Question

Remove border from code via javascript

I am working on a project where I am giving a wire frame to a user.On a click I trigger the changes on another page..

So I am give the user to upload a image and write a text and on another page, home, I am displaying the result which he has committed via a click event..

So I am moving a HTML page from one page to another..My question is whether the onclick event I can remove all the borders which are present on the html page via javascript..

If we can please let me know..

Suggestions and ideas welcome..Thanks

Answer Source

You can remove the border of all your elements by using the following code:

document.getElementById("your-element").onclick = function() {
    var elements = document.getElementsByTagName("*");
    for (var i = 0; i < elements.length; i++) {
        elements[i].style.border = "0"


  • You can select all the elements of the document by using *, as in CSS, inside document.getElementsByTagName().
  • Since 'elements' is an HTMLCollection, we need to repeat the above code for each iteration.


In most modern browsers you can also use:

Array.from(document.getElementsByTagName("*")).forEach(function(i) {
    i.style.border = "0";