1

Is there a way to get a text inside a span that located inside a div where the only identifier is a class name? Thanks

    <div class="popup-footer-btns-wrapper"> <!-- ngIf: popup.buttons.OK -->
    <button sf-button="" sf-name="popup-ok" ng-if="popup.buttons.OK" ng-
    disabled="okLocked || popup.buttons.OK.disabled()" ng-click="ok()" ng-
    class="popup.buttons.OK.colour ? popup.buttons.OK.colour : 'grey'" 
    class="popup-footer-button ng-scope ng-isolate-scope sf-button sf-
    button-ext grey" style="">
    <span class="sf-button-ext__content"><ng-
    transclude>Apply</ng-transclude></span>
    </button><!-- end ngIf: 
    popup.buttons.OK --> <button sf-name="popup-cancel" class="popup-footer-
    button sf-link underline ng-binding" ng-click="cancel()">Cancel</button> 
    </div>
Shay12345678
  • 113
  • 1
  • 9

1 Answers1

0

With the help of below line, you will get the text of span sf-button-ext__content

document.getElementsByClassName('sf-button-ext__content')[0].textContent;

Try the below javascript,

window.onload = function() {
  var element = document.getElementsByClassName('sf-button-ext__content');
  console.log(element[0].textContent);
}
<div class="popup-footer-btns-wrapper">
  <!-- ngIf: popup.buttons.OK -->
  <button sf-button="" sf-name="popup-ok" ng-if="popup.buttons.OK" ng- disabled="okLocked || popup.buttons.OK.disabled()" ng-click="ok()" ng- class="popup.buttons.OK.colour ? popup.buttons.OK.colour : 'grey'" class="popup-footer-button ng-scope ng-isolate-scope sf-button sf-
    button-ext grey" style="">
    <span class="sf-button-ext__content"><ng-
    transclude>Apply</ng-transclude></span>
    </button>
  <!-- end ngIf: 
    popup.buttons.OK --><button sf-name="popup-cancel" class="popup-footer-
    button sf-link underline ng-binding" ng-click="cancel()">Cancel</button>
</div>
Pawan Kumar
  • 1,374
  • 7
  • 14