2

I want to extract the text value with javaScript from this below HTML:

<div class="search-box-compact__label text-color-secondary">
   <span data-bind="i18n: 'search.keyword-label'">Find Jobs</span>
</div>

I have tried this but its not working. Kindly suggest a solution:

  let y = document.querySelectorAll("[data-bind=`i18n: 'search.keyword-label'`]");

I am getting the following errors::

Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': '[data-bind=`i18n: 'search.keyword-label'`]' is not a valid selector.

Kindly suggest.

1 Answer 1

3

You need to escape ', i used " too

let y = document.querySelectorAll("[data-bind=\"i18n: \'search.keyword-label\'\"]");
console.log(y);
<div class="search-box-compact__label text-color-secondary">
   <span data-bind="i18n: 'search.keyword-label'">Find Jobs</span>
</div>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.