Hmahwish
Hmahwish

Reputation: 2232

Set focus on the first input field on dropdown toggle through angular js

<th class="dropdown" id="header">
  <span>Label</span>
    <span id="filter" class="sort_row glyphicon glyphicon-filter   dropdown-toggle" data-toggle="dropdown" ></span>
  <ul class="dropdown-menu filter-dropdown" role="menu">
     <li >
  <span class="input-group value">
<input type="text"  id="inputField1" name="inputField1"  class="form-  control" ng-model='inputFieldFirst'/>
        </span>
       </li>
      </ul>
   </span>
 </th>

Here I want to focus on the input field when the filter is clicked and the dropdown opens. Is there a way in which I dont have to use the id of the input field and set focus on the input that is present in the dropdown

Upvotes: 1

Views: 1484

Answers (1)

Kovalcsik
Kovalcsik

Reputation: 48

I probably try this.

$( "#filter" ).click(function() {
  $( ".dropdown-menu input:first-child()" ).focus();
});

Upvotes: 1

Related Questions