javascript从wkwebview目标c中的HTML中删除div标记
我有如下HTML字符串javascript从wkwebview目标c中的HTML中删除div标记,javascript,html,objective-c,wkwebview,Javascript,Html,Objective C,Wkwebview,我有如下HTML字符串 <header><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'></header><!DOCTYPE html><html><head><style> * { word-wr
<header><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'></header><!DOCTYPE html><html><head><style> * { word-wrap: break-word; } </style> </head> <body><div style="box-sizing: border-box; font-family: 'Segoe UI', 'Helvetica Neue', 'Apple Color Emoji', 'Segoe UI Emoji', Helvetica, Arial, sans-serif; font-size: 14px;"><div data-tid="messageBodyContainer"><div data-tid="messageBodyContent"><div>Thanks for agreeing n. I'm xyz at The and I'll serve as the moderator for the board. We'll be discussing your interactions with each other :</div><div>1) The class will be open for 2 days April 24 and April 25. Please ask questions each day, and read book.2) The approximate time commitment to the books is 30 minutes each day.</div><div></body></html>
请帮助我没有注意到在您的html示例中有任何id=“id2”的元素,您是否碰巧忽略了这些元素?我对javascript不太在行。我不确定要传递哪个参数以及传递到哪里。请给出一个示例,说明您正试图从html中删除哪些内容--问题中不清楚我没有注意到在您的html示例中有任何id=“id2”的元素,您是否碰巧忽略了这些元素?我对javascript不太熟悉。我不确定要传递哪个参数以及传递到哪里。请给出一个示例,说明您正试图从html中删除哪些内容——这个问题还不清楚
<header><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'></header><!DOCTYPE html><html><head><style> * { word-wrap: break-word; } </style> </head> <body><div><span style="font-size: 16px;"><span style="font-size: 16px; font-family: Arial;">Hello and welcome to XXXXXXX bulletin board session! </span><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</span><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</span><span style="font-family: Arial;">Over the next 3 days...</span></span></div><ul> <li><span style="font-size: 16px;"><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </span> </span></li> <li><span style="font-size: 16px;"><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. </span> </span></li> <li><span style="font-size: 16px;"><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</span> </span></li> <li><span style="font-size: 16px;"><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and type setting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </span> </span></li> <li><span style="font-size: 16px;"><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</span> </span></li> <li><span style="font-size: 16px; font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</span></li></ul></body></html>
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
NSString *jsCommand = [NSString stringWithFormat:
@"var element = document.getElementById('%@'); element.parentElement.removeChild(element);",
@"id2"];
[webView evaluateJavaScript:jsCommand completionHandler:^(id _Nullable stringresult, NSError * _Nullable error) {
NSLog(@"result=>%@ error->%@",stringresult,error);
}];
}