I have <li>
elements in my document such as:
<li id="123" onMouseOver="foo();">Lorem Ipsum ...
I would like to remove the attributes and get the string <li>Lorem Ipsum ...
. In order to do that, I use the replace()
method:
foo = document.getElementById('bar');
alert(foo.innerHTML.replace('<li(.*)', '<li>'));
But it won't match and returns the exact same string. <li\(.*\)
was no good either. I tried the regex here and it worked. Any suggestions? Would DOM solve this instead of Regex?
EDIT: Turns out I used the replace method wrong, instead of a pattern I should have provided a Regexp
object. Thanks to Gobi's answer I corrected my pattern too.