title: jQuery.focus() function not working
body: <p>Using the jQuery <code>focus()</code> method does not seem to work if I use it like this:</p>
  
  <pre><code>$('#&lt;same_id_input&gt;').focus();
  </code></pre>
  
  <p>When click in label I call a function to display a div with inputs inside and then I call the <code>focus()</code> on the <code>&lt;input&gt;</code> elements but it's not working.</p>
  
  <p>I'm using:
  Boostrap 3.3.7 + jQuery 3.1.1</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('#optBusqueda .btn').click(function(){
      var radioSeleccionado=$(this).find(':radio').first();
      if(radioSeleccionado &amp;&amp; radioSeleccionado.length&gt;0){
          $('#divBuscarOcr').css("display","none");
          $('#divBuscarNombre').css("display","none");
          $('#divBuscarRfc').css("display","none");
          $('#divBuscarCurp').css("display","none");
          var idRadioSeleccionado=radioSeleccionado.attr('id');
          switch(idRadioSeleccionado){
              case "radioBuscarOcr":
                  $('#divBuscarOcr').css("display","block");
                  $('#txtBuscarOcr').focus();
                  break;
              case "radioBuscarNombre":
                  $('#divBuscarNombre').css("display","block");
                  $('#divBuscarNombre').focus();
                  break;
              case "radioBuscarRfc":
                  $('#divBuscarRfc').css("display","block");
                  $('#divBuscarRfc').focus();
                  break;
              case "radioBuscarCurp":
                  $('#divBuscarCurp').css("display","block");
                  $('#divBuscarCurp').focus();
                  break;
          }
          
      }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://code.jquery.com/jquery-3.1.1.min.js"&gt;&lt;/script&gt;
  &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
  
  &lt;div class="panel-group" id="accordion" role="tablist"
      aria-multiselectable="true"&gt;
      &lt;div id="panelBuscar" class="panel panel-default"&gt;
        &lt;div class="panel-heading clearfix" role="tab" id="headingOne"&gt;
          &lt;!-- data-toggle="collapse" data-target="#collapseOne" --&gt;
          &lt;h4 class="panel-title pull-left" style="padding-top: 7.5px;"&gt;
            &lt;a role="button" data-toggle="collapse" data-parent="#accordion"
              href="#collapseOne" aria-expanded="false"
              aria-controls="collapseOne"&gt; &lt;i
              class="fa fa-lg fa-fw fa-search"&gt;&lt;/i&gt; BUSCAR
            &lt;/a&gt;
          &lt;/h4&gt;
          &lt;div id="optBusqueda" class="btn-group pull-right"
            data-toggle="buttons"&gt;
            &lt;label class="btn btn-primary active" data-toggle="tooltip" title="Buscar por OCR"&gt; &lt;input
              name="options" id="radioBuscarOcr" type="radio" checked="true" /&gt;
              OCR
            &lt;/label&gt; &lt;label class="btn btn-primary"  data-toggle="tooltip" title="Buscar por Nombre"&gt; &lt;input name="options"
              id="radioBuscarNombre" type="radio" /&gt; NOMBRE
            &lt;/label&gt; &lt;label class="btn btn-primary"  data-toggle="tooltip" title="Buscar por RFC"&gt; &lt;input name="options"
              id="radioBuscarRfc" type="radio" /&gt; RFC
            &lt;/label&gt; &lt;label class="btn btn-primary"  data-toggle="tooltip" title="Buscar por CURP"&gt; &lt;input name="options"
              id="radioBuscarCurp" type="radio" /&gt; CURP
            &lt;/label&gt;
          &lt;/div&gt;
          &lt;div class="pull-right" id="divMunicipioBuscar"&gt;
            &lt;div class="form-group" style="margin-bottom: 0"&gt;
              &lt;select id="txtNoMunicipioBuscar" name="txtNoMunicipioBuscar"
                th:attr="data-url=@{/municipios/get},data-emptyText='Seleccione municipio'"
                class="form-control populateSelect"&gt;
                &lt;option value=""&gt;Seleccione municipio...&lt;/option&gt;
              &lt;/select&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div id="collapseOne" class="panel-collapse collapse in"
          role="tabpanel" aria-labelledby="headingOne"&gt;
          &lt;div class="panel-body"&gt;
            &lt;div class="row"&gt;
              &lt;div class="col-sm-4 " id="divBuscarOcr"&gt;
                &lt;div class="form-group"&gt;
                  &lt;input id="txtBuscarOcr" name="txtBuscarOcr" type="text"
                    class="form-control" placeholder="Ocr" /&gt;
                &lt;/div&gt;
              &lt;/div&gt;
              &lt;div id="divBuscarNombre" style="display: none;"&gt;
                &lt;div class="col-sm-3"&gt;
                  &lt;div class="form-group"&gt;
                    &lt;input id="txtNombreBuscar" name="txtNombreBuscar" type="text"
                      class="form-control" placeholder="Nombre" /&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="col-sm-3"&gt;
                  &lt;div class="form-group"&gt;
                    &lt;input id="txtApPaternoBuscar" name="txtApPaternoBuscar"
                      type="text" class="form-control" placeholder="Apellido Pat." /&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="col-sm-3"&gt;
                  &lt;div class="form-group"&gt;
                    &lt;input id="txtApMaternoBuscar" name="txtApMaternoBuscar"
                      type="text" class="form-control" placeholder="Apellido Mat." /&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
              &lt;div id="divBuscarRfc" style="display: none;"&gt;
                &lt;div class="col-sm-4 "&gt;
                  &lt;div class="form-group"&gt;
                    &lt;input id="txtBuscarRfc" name="txtBuscarRfc" type="text"
                      class="form-control" placeholder="Rfc" /&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
              &lt;div id="divBuscarCurp" style="display: none;"&gt;
                &lt;div class="col-sm-4 "&gt;
                  &lt;div class="form-group"&gt;
                    &lt;input id="txtBuscarCurp" name="txtBuscarCurp" type="text"
                      class="form-control" placeholder="Curp" /&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
              &lt;a id="btnBuscar" class="btn btn-default"
                onclick="busquedaCiudadano(this)"&gt;&lt;i
                class="fa fa-lg fa-search"&gt;&lt;/i&gt; Buscar&lt;/a&gt;
            &lt;/div&gt;
            &lt;div id="divResultados"&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is my original example on <a href="https://jsfiddle.net/snessnes/4xbLL81v/2/" rel="nofollow noreferrer">JSFiddle</a>.</p>