javascriptng-bind

JavaScript get span value from “ng-bind”


There are many similar posts but I can't find my solution.

My code is:

<span ng-bind="selected.S_date" class="ng-binding">Different value all the time here.</span>

I want to get the value Different value all the time here from the span.

I can do

document.getElementsByClassName('ng-binding')[55].textContent

Here the 55 is dynamic, value change. Found Python + Selenium: get span value from "ng-bind" but I want to do with JavaScript.

Want to do similar is JavaScript?


Solution

  • The solution suggested by Heretic Monkey on the comment.

    document.querySelector("span[ng-bind='selected.S_date']")