数码资讯
jQuery实现了在光标位置插入内容的方法。
本文演示了jQuery在光标位置实现内容插入的方式,供大家参考,具体实现方法如下: 复制代码代码如下所示: 无标题页 (函数($){) fn.extend({美元。 InsertAtCaret:功能(自我价值){ var $ $ =($){ 0 }; 如果(文档选择){ This.focus();
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
本文演示了jQuery在光标位置实现内容插入的方式,供大家参考,具体实现方法如下:
复制代码代码如下所示:
无标题页
(函数($){)
fn.extend({美元。
InsertAtCaret:功能(自我价值){
var $ $ =($){ 0 };
如果(文档选择){
This.focus();
SEL = document.selection.createrange();
sel.text =自我价值;
This.focus();
别的}
如果($ t.selectionstart | | t.selectionstart美元= = '0')
{
VaR StartPos = t.selectionstart美元;
VaR EndPos = t.selectionend美元;
VaR scrollTop = $ t.scrolltop;
t.value = t.value.substring(0美元美元,让美元)+自我价值+ t.value.substring(EndPos,t.value美元。长度);
This.focus();
t.selectionstart美元= Startpos + myvalue.length;
t.selectionend美元= Startpos + myvalue.length;
t.scrolltop美元= scrollTop;
{人}
this.value =自我价值;
This.focus();
}
}
})
}(jQuery);
$(文档)Ready(函数(){)
$(# numd)。Bind(MouseLeave
document.getelementbyid('keybored)。Style.display =不关;
Document.getElementById ('Nm').Blur ();
});
$(# nm)。焦点(函数(){)
document.getelementbyid('keybored ' Style.display ');
});
$(。readbtns)。Click(function(){)
$(# nm)。InsertAtCaret($(this)。瓦迩());
});
});
< DIV style=显示:无;border: 1px solid # a2b4c6;宽度:150px;身高:400px;
id=keybored>
希望本文能对大家的jQuery程序设计有所帮助。
复制代码代码如下所示:
无标题页
(函数($){)
fn.extend({美元。
InsertAtCaret:功能(自我价值){
var $ $ =($){ 0 };
如果(文档选择){
This.focus();
SEL = document.selection.createrange();
sel.text =自我价值;
This.focus();
别的}
如果($ t.selectionstart | | t.selectionstart美元= = '0')
{
VaR StartPos = t.selectionstart美元;
VaR EndPos = t.selectionend美元;
VaR scrollTop = $ t.scrolltop;
t.value = t.value.substring(0美元美元,让美元)+自我价值+ t.value.substring(EndPos,t.value美元。长度);
This.focus();
t.selectionstart美元= Startpos + myvalue.length;
t.selectionend美元= Startpos + myvalue.length;
t.scrolltop美元= scrollTop;
{人}
this.value =自我价值;
This.focus();
}
}
})
}(jQuery);
$(文档)Ready(函数(){)
$(# numd)。Bind(MouseLeave
document.getelementbyid('keybored)。Style.display =不关;
Document.getElementById ('Nm').Blur ();
});
$(# nm)。焦点(函数(){)
document.getelementbyid('keybored ' Style.display ');
});
$(。readbtns)。Click(function(){)
$(# nm)。InsertAtCaret($(this)。瓦迩());
});
});
< DIV style=显示:无;border: 1px solid # a2b4c6;宽度:150px;身高:400px;
id=keybored>
希望本文能对大家的jQuery程序设计有所帮助。
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。