في مقالة إدخال Flashback في مربع النص ، رمز JavaScript الذي يحدد تركيز مربع النص ، واليوم سأستخدم هذا الرمز لصنع عرض تجريبي. المحتوى هو حذف الكلمة بأكملها في وقت واحد عند حذف كلمة ، كما هو موضح في الشكل:
سأقوم بنشر نموذج رمز أدناه:
<! doctype html> <html> <head> <title> </title> <meta http-equiv = "content-type" content = "text/html ؛ charset = utf-8"> src = "http://cdn.staticfile.org/jquery/2.1.1-rc2/jquery.min.js"> </script> </head> <body> <viv> <sistarea name = "" id = "demo" cols = "Rows =" 10 " {var caretpos = 0 ؛ // ie supportif (document.selection) {ctrl.focus () ؛ var sel = document.selection.createRange () ؛ sel.movestart ('character' ، -ctrl.value.length) ؛ caretpos = cel.text.length ؛ ==== 0) {caretpos = ctrl.selectionStart ؛} return (caretpos) ؛} ؛ var selectsometext = function (element ، end ، end) {if (element.setSelectionRange) {element.SetSelectionRang element.createTexTrange () ؛ Range.movestart ("حرف" ، بداية) ؛ Range.moveend ("حرف" ، نهاية) ؛ Range.Select () ؛}} ؛ var delwholeword = function (النص ، الحقل ، pos) {var startIndex = pos ؛ if (field.charat (pos-1)! == ') (field.charat (i) === '' || i === 0) {startIndex = i ؛ break ؛}} selectsometext (النص ، startIndex ، pos)}} ؛ $ ('#demo'). keydown (function (event) {if (event.keycode! == 8) {return ؛} var bodytext = $ (هذا) [0] getCursortPosition (bodytext) ؛ delWholeword (bodytext ، bodyfield ، pos) ؛}) ؛ </script> </body> </html>