i want log comments in script tags in html document. how can ?
<!doctype html> <html> <body> <script> //my comment var test = "some js"; /* start of comment ... end of comment*/ </script> <!-- comment --> <p>this paragraph.</p> </body> </html> for now, have snippet of code html comments
var jq = document.createelement('script'); jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"; document.getelementsbytagname('head')[0].appendchild(jq); jquery.noconflict(); $(function() { $("*").contents().filter(function(){ return this.nodetype == 8; }).each(function(i, e){ console.log(e.nodevalue); }); }); will return : comment
Comments
Post a Comment