+ 3

Using JavaScript to remove comment tags

Is it possible to remove HTML or CSS comment tags using JavaScript For example making it so when a button is clicked , a bunch of new code appear by removing the comment tags

16th Mar 2019, 1:13 PM
Mario
Mario - avatar
4 Answers
16th Mar 2019, 2:27 PM
CalviÕ²
CalviÕ² - avatar
+ 7
Possible. Just use regex, replace every instance of /<!--(.|\n)*-->/g with "". That said, your JS will need to read your HTML file to do that. Not sure how that works on Code Playground.
16th Mar 2019, 1:21 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
What I can understand is all you need to dynamically change the content of the page like adding something after clicking or removing like that. There are many ways you can do depending upon what exactly you want to do. One option would be, create the element in js and add it to web page dynamically or similarly can be removed as well. Or, can create it already in html with display =none and change it in js as needed.
16th Mar 2019, 1:38 PM
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½ - avatar
- 1
Yes it is possible
28th Mar 2019, 12:50 PM
Abubacarr Gibba
Abubacarr Gibba - avatar