title: angularjs not focussing on next element
body: <p>my html code:</p>
  
  <pre><code>&lt;div ng-app="app"&gt;
  &lt;form&gt;
      &lt;div class="form-group"&gt;
        &lt;label &gt;Username&lt;/label&gt;
        &lt;input focus type="text" class="form-control" id="loginUserName" ng-model="userForm.crn" required/&gt;  
        &lt;/div&gt;
       &lt;div class="form-group"&gt;
        &lt;label &gt;Password&lt;/label&gt;         
         &lt;input focus type="password" class="form-control" id="loginPwd" ng-model="userForm.password"  required/&gt;
       &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p>my js Code:</p>
  
  <pre><code>var app = angular.module('app', []); app.directive('focus', function () {
  return {
      restrict: 'A',
      link: function ($scope, elem, attrs) {
  
          elem.bind('keydown', function(e) {
          var code = e.keyCode || e.which;
          if (code === 13) {
            console.log(elem);
            elem.next()[0].focus();
            //e.preventDefault();
            //elem.next().focus();
          }
        });
      }
  }
  })
  </code></pre>
  
  <p>1: this code does not focus on next element when enter button is clicked. it shows 
  nextElementSibling: null and nextSibling: text on <code>console.log(elem)</code>
  2: but when i remove tag label and div  in form tag, it starts working as it focuses on next element.</p>
  
  <p>so, Question is how do i make it work without removing div and label. why is the nextElementSibling coming null?</p>
  
  <p><a href="https://jsfiddle.net/Y2XLA/110/" rel="nofollow">this is fiddle link of this code</a></p>