-1

I have a website that is built using NetSuite, meaning I don't have control of he source html. The code that's output looks like this. I would like to remove the piece of code that starts with "I want to remove starting here".

                  </td>
              <!-- end new category page -->
              <!-- I want to remove starting here -->               
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
    <tr valign="top">
      <td width="100%">
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tbody>
            <tr> 
              <!-- I want to remove ending here -->
              <!-- start Category Page Item List SubCategories -->
              <td width="65%" style="font-family: &#39;Lato&#39;, sans-serif; font-weight:400;">
5
  • 1
    have you tried anything? Commented Nov 6, 2017 at 15:43
  • I don't think javascript can do anythign with comments. The only way to do this is to get the value inside the parent, and replace it without the comment. Commented Nov 6, 2017 at 15:45
  • I tried Googling the answer, and found a number of people asking about removing entire elements, but I'm looking to remove the ending of some elements and the corresponding beginning of other elements. So I'm not sure how to approach that. Commented Nov 6, 2017 at 15:46
  • The code isn't actually commented out...I just put comments around it to show which piece of the dom I'm trying to remove. Commented Nov 6, 2017 at 15:47
  • What you actually want to do is to combine two different tables into one, by removing the ending tags of the first table. As far as I know, even with jQuery, you can't remove end tags, but a whole element, or only what is inside it. I think you'll have to search more. What I would suggest is to completely rewrite your HTML as 1 Table, using jQuery, after the DOM is ready. More work, but more simple, I think... EDITED: What you want to achieve is impossible LINK HERE.. You should go with another solution/hack/workaround Commented Nov 6, 2017 at 15:54

1 Answer 1

0

Your question is essentially the same as in this post

You are asking to access the comments in the DOM using javascript.

Sign up to request clarification or add additional context in comments.

2 Comments

That's not what I'm asking. The section I want to remove is not commented out. I just put comment tags around it to highlight which section of the dom I am trying to remove.
Yeah, that wasn't entirely clear. Your problem is still accessing the DOM (Document Object Model) in javascript in the right way. You can move all of your <td>s into one table. Another approach which i suspect you prefer is to simply manipulate the "InnerHTML" of whichever element surrounds your code snippet above. It's a hack but it seems like what you want to do. Pull out all the InnerHTML to a string and replace the code block you want to remove with a string substitution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.