I have a list like this:
<ul class="tabs-dropdown">
<li><a href="/home">Home</a></li>
<li>
<a href="javascript:">French Alps</a>
<div>
<ul>
<li><a href="/region/french-alps/about">About</a></li>
<li><a href="/region/french-alps/properties">Properties</a></li>
</ul>
</div>
</li>
<li>
<a href="javascript:">Swiss Alps</a>
<div>
<ul>
<li><a href="/region/swiss-alps/about">About</a></li>
<li><a href="/region/swiss-alps/properties">Properties</a></li>
</ul>
</div>
</li>
<li><a href="/finance">Finance</a></li>
<li><a href="/contact">Contact Us</a></li>
</ul>
and some javascript like this:
var element = angular.element(document.querySelector('ul'));
element.children().on('focusin', function () {
angular.element(this).addClass('focused');
}).on('focusout', function () {
angular.element(this).removeClass('focused');
});
Here is the fiddle with all the code
Basically, I want the first level list elements to become red when any of their descendents have focus. I am listening for the focusin and focusout events on the first level list elements to achieve this.
The best way to apply focus to the elements in the example is to tab to them.
This works fine in Chrome and IE but not in Firefox and I can't think why.
Any help would be greatly appreciated.
If you are wondering why I am doing this in AngularJS and not jQuery, its because this code is part of an Angular directive and this is just the bit that doesn't work.