jquery - Uncomment html code using javascript -
HTML tags with some comment tags I just wanted to delete those tags I tried regex to use javascript But the problem completely removes the comment line, where I wanted to delete those tags. Below the sample HTML table with comment tags ...
& lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; ABCD & lt; / TD & gt; & Lt; TD & gt; Logic & lt; / TD & gt; & Lt ;! - & lt; Td> 26538568 & lt; / Td> - & gt; & Lt; / TR & gt; & Lt; / Table & gt;
So in the code above I just & lt ;! - & lt; Td> 26538568 & lt; Td> - & gt;
. This is part of the scrap data from the webpage, so I can not change the html code. The table structure above is similar to the Web page, from which I am trying to extract the data.
For example, using the DOM, without the text as you can, jQuery Usage:
$ ('table tr') .contents () .filter (function () {return.nodeType === 8;}) // Get comments with reverse with (function () {This.data return}}
Here's an interesting bit, which gives all the nodes not only elements - it includes text nodes and comments.
Example:
Warning note: I do not know how this cross-browser is I particular, it is possible node.data is not supported I tested Firefox, Chrome and IE the code 10.
Comments
Post a Comment