js 文字框文字域focus時自動選中內容

2022-03-16 08:57:28 字數 1459 閱讀 8605

>自動選擇

title

>

<

link

rel="stylesheet"

href

="">

head

>

<

body

>

<

h1>focus時自動選中內容

h1>

<

input

type

="text"

autoselect start

="2"

end="4"

value

="這是內容這是內容這是內容"

>

<

br><

br>

<

textarea

autoselect

>這是內容這是內容這是內容

textarea

>

<

script

src=""

integrity

="sha256-fgpcb/kjqllnfou91ta32o/nmzxltwro8qtmkmrdau8="

crossorigin

="anonymous"

>

script

>

<

script

>/**

* 自動選擇文字框/文字域中的內容

* @param e [必填,必須是input或者textarea]

* @param s [預設:0]

* @param t [預設:總長度]

* @return [null]

*/function

autoselect(e,s,t)

else

if(e.createtextrange)

e.focus();}$(

"[autoselect]

").on(

"focus",

function

(e));

script

>

body

>

html

>

效果:

js 文字框限制

keyup this.value this.value.replace d g,onafterpaste this.value this.value.replace d g,2.只能輸入數字,能輸小數點.keyup if isnan value execcommand undo onafterpas...

js處理富文字框

通過js向富文字框輸入 我很好 public void setcontent string content contentdocument 容納框架的內容的文件。返回 frame iframe 生成的文件物件。contentwindow 返回 frame iframe 生成的 window 物件。d...

文字框日曆

建立頭部 document.write 734 8 建立星期條目 document.write for i 0 i 7 i document.write week i document.write 建立日期條目 document.write for i 0 i 6 i document.write ...