有没有办法在div内部获取文本,该文本位于div中,唯一的标识符是类名? 感谢
<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>
答案 0 :(得分:0)
在以下行的帮助下,您将获得text
的{{1}}
sf-button-ext__content
尝试以下javascript,
document.getElementsByClassName('sf-button-ext__content')[0].textContent;
window.onload = function() {
var element = document.getElementsByClassName('sf-button-ext__content');
console.log(element[0].textContent);
}