Remove Element (OR) Elements Attribute - Yash-777/SeleniumDriverAutomation GitHub Wiki
Sample HTML page DOM source.
<body class='body class' >
<div id="example">
<p id="p0" class="aaa"> aaa </p>
<p id="p1" class="aaa bbb"> aaa bbb </p>
</div>
</body>
Removing HTMLElement form DOM
function removeTag( nodeElement ){
nodeElement.parentNode.removeChild( nodeElement );
}
var ele = document.getElementById("p1");
removeTag( ele );
Removing HTMLElements attribute.
function removeTagAttibute( tags, attributeName ){
var allelems = document.querySelectorAll( tags );
for(i = 0, j = 0; i < allelems.length; i++) {
allelems[i].removeAttribute( attributeName );
}
}
var specificTags = ['ARTICLE', 'INPUT']; // allTags = '*';
var attributeName = 'class'; // class, id, src, tabindex, ...
removeTagAttibute( 'body', attributeName );