No artigo de entrada de flashback da caixa de texto, o código JavaScript que define o foco da caixa de texto e hoje usarei esse código para fazer uma demonstração. O conteúdo é excluir a palavra inteira imediatamente ao excluir uma palavra, como mostrado na figura:
Vou postar o código de exemplo abaixo:
<! Doctype html> <html> <head> <title> </title> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"> <yoy> .content {width: 300px; margin: 0 auto; src = "http://cdn.staticfile.org/jquery/2.1.1-rc2/jquery.min.js"> </script> </ad Head> <body> <div> <texttarea name = "id =" Demo "Cols =" 30 "ROWS =" 10 "> </textarea> {var caretpos = 0; // ie supportif (document.selection) {ctrl.focus (); var sel = document.selection.createrange (); sel.movestart ('caractere', -ctrl.value.length); caretpos = sel.lext.lengthen;} // firefox supportSelse se if (coTpos = Sel.lext.Length; 0) {caretpos = ctrl.SelectionStart;} return (caretpos);}; var selectSomeText = function (elemento, iniciar, end) {if (element.SeSeSelectionRange) {Element.SetSelectionRange (BEGIN); element.CreateTeTexTrange (); range.Movestart ("caractere", BEGIN); range.movend ("caractere", end); range.select ();}}; var delwholeword = function (text, campo, POS) {var startIndex = pos; if (field.Charat (iP-1)! === '' || i ==== 0) {startIndex = i; quebrar;}} selecionSomeText (text, startIndex, pos)}}; $ ('#Demo'). KeyDown (function (event) {if (event.keycode! == 8) {return;} var BodyText = $ (this) [0]; varfody! getCursortPosition (BodyText); Delwholeword (BodyText, Bodyfield, POS);}); </sCript> </body> </html>