javascript - jquery after appendTo cannot focus on input box -
After adding the input box to another element, it will not allow the click in the box (the focus immediately goes away). why will? Here
HTML
& lt; Div id = "placeholder" onclick = "appendsearch ()" & gt; Placeholder & lt; / Div & gt; & Lt; Input id = 'box' type = 'text' & gt; & Lt; / Input & gt;
JS
function append search () {$ ("# box"). AppendTo ($ ("$ placeHolder")}}
An attachment method that returns input The reason for losing focus is because the input is now in the div, and it is calling the function on click, the following code will be the account for it.
function append search () (if ($ ("# spacehold input"). Length == 0) {$ ("# box"). AppendTo ($ ("#placeholder") );}}
Comments
Post a Comment