I was wondering if there's a way in javascript that allows me to process the html source code that allows me to take out specific tags that I want?
Sorry if it sounds easy or too simple. i am new to programming.
I was wondering if there's a way in javascript that allows me to process the html source code that allows me to take out specific tags that I want?
Sorry if it sounds easy or too simple. i am new to programming.
If you have the HTML in a string, then you can use:
Alternately, use jQuery. jQuery is a library to help you manipulate and access HTML elements more easily. First, add this to the head of your document:
This is a reference to the jQuery library. Then, do:
Or, if your html is in a variable (e.g. str), you can do:
Then, you can manipulate and parse foo in a number of ways. For example, to remove all paragraph elements, you would use
Or, to remove the paragraph element with id="bar", use:
Once you are done your modifications, you can get the new html text using:
Why is your html in a string? Is it not the html of the current page?
Use DOM it can pull data from webpages if you know the structure.