hi,
how do i use this code with jquery, i know it's easy but it doesn't work for me.
document.getElementsByTagName('html')[0].innerHTML.replace(/<!--|-->/g,'')
hi,
how do i use this code with jquery, i know it's easy but it doesn't work for me.
document.getElementsByTagName('html')[0].innerHTML.replace(/<!--|-->/g,'')
This should work for you. Remember you can use javascript and jQuery together. Try this:
$("<html>").html($("<html>").html().replace(/<!--|-->/g,''));
Probably not the most elegant solution, but should work. Are you familiar with:
If your intention is to generate a new string where all <!--
and -->
are removed then your code works just fine. If not then you probably should be reminded that in javascript, a String's replace()
method does not replace anything in that string, it generates a new string. So:
var html = document.getElementsByTagName('html')[0];
html.innerHTML = html.innerHTML.replace(/<!--|-->/g,'');
But your question is very odd. Why would you want to do this? Perhaps you want to uncomment some commented out code? This does not look like something that is safe to do.