I have two elements:
- A texfield element, firstly hidden.
- And a button element covering the textfield.
In other hand, I have one event called onDoubleClick which calls a function when a double click is made in the button. This function hides the button and show the textfield, but I need that the textfield is editable in this moment (like make a third click)
I read about focus() but it doesn’t help me… http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_html_blur
How can I obtain it?
EDIT:
I’m obtaining well the input element:
var htmlElement = document.getElementById(this._tabsTitle[pos]._hPath);
var input = htmlElement[0];
input.focus();
The htmlElement var is a form, and the input var is the input field, I obtain it well, I’m looking with chrome inspector, with debugger, but focus() doesn’t work…
SOLUTION
It’s was mine mistake…this code is part of a big project, and focus was working fine, but didn’t make anything due to a thread problem … I checked it and solved it, and now it works like a charm 🙂 thanks to all
Regards, Daniel
check this fiddle. I believe it does what you want.
html
js
UPDATED according to comments on top(below question).
if you dont want the button to be hidden and make its value null.
replace the line
by