JavaScript JavaScript Focus not working javascript focus not working,javascript focus not working in chrome,

Javascript focus is not working in my code.

HTML

<div class="col-md-6" style="border:none; margin-top:2px; padding-right:5px">
    <input type="text" id="edtunt" ng-model="Unit" class="form-control" placeholder="Edit Unit" />
</div>

Javascript

var textbox = document.getElementById('edtunt');
//document.getElementById("edtunt").focus();
document.getElementById("edtunt").focus();
$scope.Unit = unit.name;
Answer:1

use tabindex="0" for making div focusable

Answer:2

Your code works:

document.getElementById('edtunt').focus();
<div class="col-md-6">
  <input 
    type="text" 
    id="edtunt" 
    ng-model="Unit" 
    class="form-control" 
    placeholder="Edit Unit">
</div>
Answer:3

I searched on stackoverflow a bit and couldn't find an exact answer to this problem. I have some tabs on my webpage. I want when a user clicks a tab to place an active tag on the tab the user picked ...

I searched on stackoverflow a bit and couldn't find an exact answer to this problem. I have some tabs on my webpage. I want when a user clicks a tab to place an active tag on the tab the user picked ...

  1. issue tabs jira
  2. session issue with multi tabs in a browser
  3. issue tabs
  4. issue tabs redmine

I have a redux container which I want to mount in my test case. It has a component which is using react-router link. Mounting the container was throwing me history not defined error, after reading ...

I have a redux container which I want to mount in my test case. It has a component which is using react-router link. Mounting the container was throwing me history not defined error, after reading ...

I'm implementing Immutable.js in a set of React components with props containing objects, where Immutable has not been used before. While I was rewriting all { someProp.someValue } to { someProp.get("...

I'm implementing Immutable.js in a set of React components with props containing objects, where Immutable has not been used before. While I was rewriting all { someProp.someValue } to { someProp.get("...

  1. immutable javascript to object
  2. immutable in javascript
  3. immutable in javascript w3schools

Previously, I was able to reroute user (e.g. on successful login) using browser history: import { browserHistory } from 'react-router' browserHistory.replace('/home') In the new react-router I am ...

Previously, I was able to reroute user (e.g. on successful login) using browser history: import { browserHistory } from 'react-router' browserHistory.replace('/home') In the new react-router I am ...