I need to call a click operation in native javascript. I got the following element:
<svg class="pull-right svg-cross ng-isolate-scope" xmlns="http://www.w3.org/2000/svg" data-svg-icon="" icon="cross" ng-click="dismissBanner()">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#svg-cross"></use>
</svg>
I seems to be a website that uses angular. I would like to click on the element such that the function dismissBanner()
gets properly called. Therefore I tried the following:
document.getElementsByClassName('pull-right svg-cross ng-isolate-scope')[0].click();
and
document.getElementsByClassName('pull-right svg-cross ng-isolate-scope')[0].onclick();
However, both attempts have failed. I get the error Uncaught TypeError: document.getElementsByClassName(...)[0].onclick is not a function(…)
.
I also called the dismissBanner();
function directly, however, then I get the error: Uncaught ReferenceError: dismissBanner is not defined(…)
How should I do that correctly?