OC代码
1 2 3 4 |
NSString *tempString = [NSString stringWithFormat: @"var testa = document.getElementById('test');" "testa.parentNode.removeChild(testa)"]; [self.myWebView stringByEvaluatingJavaScriptFromString:tempString]; |
html示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<html> <head> <script type="text/javascript"> function delColumn(){ var test11 = document.getElementById("test"); test11.parentNode.removeChild(test11); } </script> </head> <body> <div id="test"> <h1 class="h">23213</h1> <h2 id="hh">23213</h2> </div> <input type="button" value="del"onclick="delColumn()"> </body> </html> |
转载请注明:天狐博客 » ios执行js删除某个html元素块节点