user1669730
user1669730

Reputation: 65

Removing/Stripping HTML Class from WKWebview

I am trying to remove header-padding HTML Class from WKWebview , This is the method i am using currently .

func webView(webView: WKWebView,didFinishNavigation navigation: WKNavigation){


    webView.evaluateJavaScript("document.querySelector('[header-padding​]').remove();", completionHandler: { (response, error) -> Void in

    })

}

But it does't work , here is my 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>

Any Help would be really Great . Thanks

Upvotes: 0

Views: 2366

Answers (1)

Pieter Meiresone
Pieter Meiresone

Reputation: 2052

You use the incorrect query selector. To select an element by it's class, you should use a .:

document.querySelector('.header-padding').remove();

Upvotes: 2

Related Questions