You need to find and delete the block <div aling="center">

html:

 ... <td valign="top" class="td-for-content"> <div aling="center"> ... 

    2 answers 2

    Using jQuery

     $('.td-for-content [align="center"]').remove(); 

    On pure JS using querySelector

     var elements = document.querySelectorAll('.td-for-content [align="center"]'); for(var i = 0; i < elements.length; i++){ elements[i].parentNode.removeChild(elements[i]); } 

    On pure JS oldschool

     var elements = document.getElementsByClassName('td-for-content'); for(var i = 0; i < elements.length; i++){ var childrens = elements[i].getElementsByTagName('div'); for(var j = 0; j < childrens.length; j++){ if(childrens[j].getAttribute('align') === 'center') childrens[j].parentNode.removeChild(childrens[j]); } } 
    • one
      It should be noted that [align="center"] is a CSS selector that will find all elements that have the property align="center" , if you need to find such elements only inside blocks with class="td-for-content" then you should use the selector .td-for-content > div[align="center"] - Sanya_Zol
    • one
      @Sanya_Zol thanks for the clarification, I was inattentive. Corrected the answer according to your comment. - Ivan Pshenitsyn

    You need to find all the divs with var alldiv=document.getElementsByTagName("div") . You will get a list object that has properties with numeric names (0,1,2 ...) that refer to the div objects found. Then run over this object in a cycle for(var i=0;i<alldiv.length;i=i+1) . And from each of them, take the property alldiv[i].align and check whether it equals the string "center" . If it is equal, let it execute alldiv[i].parentNode.removeChild(alldiv[i]) .