Ios 从WKWebview中删除/剥离HTML类
我正在尝试从WKWebview中删除标题填充HTML类,这是我当前使用的方法Ios 从WKWebview中删除/剥离HTML类,ios,swift,wkwebview,Ios,Swift,Wkwebview,我正在尝试从WKWebview中删除标题填充HTML类,这是我当前使用的方法 func webView(webView: WKWebView,didFinishNavigation navigation: WKNavigation){ webView.evaluateJavaScript("document.querySelector('[header-padding]').remove();", completionHandler: { (response, error) -&g
func webView(webView: WKWebView,didFinishNavigation navigation: WKNavigation){
webView.evaluateJavaScript("document.querySelector('[header-padding]').remove();", completionHandler: { (response, error) -> Void in
})
}
但它不起作用,这是我的HTML
<div class="header-padding" style="padding-bottom: 104px;">
<div class="navigation nav"><div class="nav-overlay"></div>
<header class="global-header">
<button class="search" aria-expanded="false" aria-label="show search field">
<span class="search-icon"></span>
</button>
<button class="burger" aria-expanded="false" aria-label="show main menu">
<span class="burger-menu"></span>
</button>
<a href="/content/insite.html" class="logo">
<img class="logo-img" src="/etc/logo.png" alt="">
</a>
<div class="profile" aria-expanded="false">
<div class="profileNavImg">
<img id="header_profile_image" class="avatar profileLayoutCircle profile-show" src="/content/dam" alt="">
</div>
</div>
</div>
</div>
任何帮助都会非常好。谢谢您使用了错误的查询选择器。要按元素的类选择元素,应使用
:
document.querySelector('.header-padding').remove();
您使用了错误的查询选择器。要按元素的类选择元素,应使用
:
document.querySelector('.header-padding').remove();
我认为这个答案应该对你有所帮助,因为你的Javascript是错误的。我认为应该是
document.querySelector('.header padding').remove()
我认为这个答案应该可以帮助您确定您的Javascript是错误的。我认为应该是document.querySelector('.header padding').remove()