Shimul D
Shimul D

Reputation: 443

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?

Upvotes: 0

Views: 680

Answers (1)

Shimul D
Shimul D

Reputation: 443

The solution suggested by Heretic Monkey on the comment.

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

Upvotes: 1

Related Questions