Have a query for our CSS & Xpath Selector experts - I managed to extract text using XPATH but struggling with a CSS Selector,
Here's the scenario:
<span class="piggy">
<i class="fa fa-try"></i>
<strong>euros (€) !</strong>
270,38K</span>
I can easily obtain "270,38K" using XPATH,
document.evaluate('//*[@id="wrap"]/span/text()', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent.trim();
Output -> 270,38K (success)
However, I'm unable to do so with a CSS Selector,
document.querySelector('span.piggy').innerText.trim();
Output -> euros (€) ! 270,38K (incorrect)
Can anyone help me retrieve only the text value of span (excluding children content) using a css selector?
Appreciate your assistance!