Trigger set focus to "DIV" element on click using Angular directive
<a href="#" class="skipToContent" ng-click="showContent()" title="skip-to-main-content">Skip To Main Content</a>
<div class="getFocus" role="button" tabindex="0">
<span>Am Focused</span>
</div>
When I click on this the link it should shift the focus to the div
To achieve this I wrote this piece of code PSB.
I tried using scrollIntoView(); also but not sure it'll work in all the browsers and it dint work for me too.
$scope.showContent = function() {
var x = document.querySelector('.skipToContent');
var y = document.querySelector('.getFocus');
y.focus();
console.log(document.activeElement);
});
};
Note: We cannot add ids or add classes to DOM.