Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/464.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于选择元素的UIWebView Javascript_Javascript_Jquery_Ios_Uiwebview - Fatal编程技术网

用于选择元素的UIWebView Javascript

用于选择元素的UIWebView Javascript,javascript,jquery,ios,uiwebview,Javascript,Jquery,Ios,Uiwebview,我正在UIWebView上运行JavaScript,但不幸的是它不起作用 当用户触摸网页时,我想获取触摸元素的文本,并突出显示该元素 //试过这个 [webView stringByEvaluatingJavaScriptFromString:@"document.onclick = function (e) {e.target.style.background='#ff3355'; };"]; //试过这个 [webView stringByEvaluatingJavaS

我正在
UIWebView
上运行JavaScript,但不幸的是它不起作用

当用户触摸网页时,我想获取触摸元素的文本,并突出显示该元素

//试过这个

[webView stringByEvaluatingJavaScriptFromString:@"document.onclick  = function (e) {e.target.style.background='#ff3355';          };"];
//试过这个

[webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].onclick  = function (e) {e.target.style.background='#ff3355';          };"];
当我在网络浏览器上查看时,希望它能正常工作

有人能建议正确的使用方法吗?

我找到了答案


[webView stringByEvaluatingJavaScriptFromString:@“document.ontouchstart=函数(e){e.target.style.background='#ff3355';};”

有人知道答案吗?