An html file is loaded into webview and that html contains a div like:
<div id="test">hello</div>
and iOS code as follows. However I receive always an empty value. What I am missing? Thank you
-(void)webViewDidFinishLoad:(UIWebView *)webView {
NSString *body = [self.webView stringByEvaluatingJavaScriptFromString:
@"document.getElementById('test').value"];
NSLog(@"received data: %@", body);
}
It’s a bit kludgy, but you can get to the text value (which is a text node and child of the element node you are currently using) by using the following…
Hope that helps