<script> function inserttag(){ var text=document.getElementById('con'); text.focus(); var start=text.selectionStart; var end = text.selectionEnd; var ss = text.value.substring(start, end); alert(ss); //alert(start); } </script> <form action
在找angularjs input(type='number')在获取焦点的时候,文本框内容选中效果,参考了:Select text on input focus,我直接复制他的code之后,在ionic中报"Uncaught InvalidStateError: Failed to read the 'selectionStart' property from 'HTMLInputElement': The input element's type ('number') does not su
在网上看了很多用js在光标处插入文字的代码,很多都没有用,互抄而已,浪费时间.最近用到一个新方法,可以到达这个需求.IE支持document.selection,Firefox,Chrome,Safari以及Opera都有selectionStart和selectionEnd属性. 代码如下: view source print? 01 function insertText(obj,str) { 02 if (document.selection) { 03 var
@HostListener('keydown', ['$event', '$event.keyCode']) onKeyDown($event: KeyboardEvent, keyCode) { if(keyCode !== TAB) { $event.preventDefault(); } // get value for the key const val = String.fromCharCode(keyCode); // get position const cursorPos = t
在找angularjs input(type='number')在获取焦点的时候,文本框内容选中效果,参考了:Select text on input focus,我直接复制他的code之后,在ionic中报"Uncaught InvalidStateError: Failed to read the 'selectionStart' property from 'HTMLInputElement': The input element's type ('number') does not su
仅记录一些我工作中常用的自定义js函数. 1.获取URL请求参数 //根据URL获取Id function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]);