我需要删除innerHTML 的某些部分。我已经尝试了 3 个小时了。看起来很简单。
这确实有效...
var foo = '<div id = "test" class = "hidden" style = "width: 350px"></div>';
alert(foo);
foo = foo.split('id = "test" class = "hidden" ').join('');
alert(foo);
而这并不...
var myElement = document.getElementById('kjbggk');
myElement.innerHTML = '<div id = "test" class = "hidden" style = "width: 350px"></div>';
alert(myElement.innerHTML);
myElement.innerHTML = myElement.innerHTML.split('id = "test" class = "hidden" ').join('');
alert(myElement.innerHTML);