JavaScript (js) sets the default input focus (focus)_javascript skills
WBOY
Release: 2016-05-16 17:45:04
Original
1048 people have browsed it
This function is often used in replies and quotes, that is, click the reply or quote. For example, if the input focus appears in the message input box, if anchors are used to position it, the input focus cannot be activated.
//Quote calling function function quote(name ,id){ var quoteMsg=document.getElementById(id).innerHTML; var content=document.getElementById("comment"); quoteMsg=quoteMsg.replace(//g, "~^").replace(/ / g,'n'); content.focus();//To have the focus on the right side of the text, this line of code must be in front content.value=quoteMsg '[Quote' name ']' 'n ' '——————————————————————' 'n'; //Fill in the text afterwards return false; //Cancel the function of href } //Reply the automatic name input function function backcomment(msg){ backdb=document.getElementById('comment'); backdb.focus(); backdb.value= msg 'n'; return false; //return true; Originally used anchor to position }
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn