angularjs Failed to read the 'selectionStart' property from 'HTMLInputElement':
在找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 support selection.",
尝试了
---
this.setSelectionRange(0, 9999)
---
this.selectionStart = 0;
this.selectionEnd = 999;
上面两个选中文本,我在webapp中测试的时候,需要每次双击之后才会有效果,我尝试用jQuery的select()方法来达到这个效果,再ionic编译的apk中测试可用之后,觉得这是我目前的解决方法。
directive方法代码
.directive('selectOnClick', function ($window) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.on('click', function () {
if (!$window.getSelection().toString()) {
// Required for mobile Safari
$(this).select();
}
});
}
};
})
input使用这个directive(指令)像:
<input type="text" value="test" select-on-click />
再android app中,使用type="number"也可以工作。
angularjs Failed to read the 'selectionStart' property from 'HTMLInputElement':的更多相关文章
- angularjs 1 Failed to read the 'selectionStart' property from 'HTMLInputElement':
在找angularjs input(type='number')在获取焦点的时候,文本框内容选中效果,参考了:Select text on input focus,我直接复制他的code之后,在ion ...
- select2取值报错,Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('hidden') does not support selection.
用到了 select2 组件来多选收件人,用搜狗浏览器(6.2版高速模式)在执行到如下这句时报错(Uncaught InvalidStateError: Failed to read the 'sel ...
- Uncaught InvalidStateError: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
使用 HTML5 的图片上传api的时候报如下错误: Uncaught InvalidStateError: Failed to set the 'value' property on 'HTMLIn ...
- Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
今天上传图片遇到这个报错 百度了下,网上说是input标签type=file所以导致的问题,可是我的type=hidden 解决办法: 把上面的代码改成如下问题就解决了
- react中报错Failed to set an indexed property on 'CSSStyleDeclaration': Index property setter is not supported
产生这个报错的原因是我当时将样式写到了less文件,我在div中使用的使用应该是使用className = ,而我误写了一个style = .style里面当然没有自定义的className,所以产生 ...
- jq ajax遇到的错误集合
一.错误: Uncaught InvalidStateError: Failed to read the 'selectionDirection' property from 'HTMLInputEl ...
- jquery 常见问题--转载
1 JQuery操作radio 1)获取按钮选中的值:$("input:radio:checked").val(); 2)选中或者取消选中某个Radio的方法,可以 ...
- js清空input file的值
原文:js清空input file的值 在做选择本地图片上传的功能时遇到一个问题,第一次点file按钮选择图片完成会触发onchange事件,获取文件后动态在界面上创建img标签展示,但把创建的img ...
- appium windows 命令行中运行以及targetSdkVersionFromManifest failed的解决
启动appium服务,可以通过appium.exe可执行文件启动,也可以通过命令行启动.appium.exe启动需要通过安装可执行文件,命令行启动需要通过npm安装appium.可执行文件启动方式如下 ...
随机推荐
- VS2013 :IntelliSense: 不允许使用不完整的类型
出现上述情况,一般是存在对应的头文件,但是没有引用造成的. 引用的时候要注意头文件的顺序, 本项目中的头文件一般先引入,也就是用双引号#include "xxx.h",然后是系统中 ...
- 如何实现CSS居中?–CSS居中常用方法
来源:http://www.ido321.com/824.html 一.水平居中 1.内联元素居中:相对父级块级元素居中对齐 1: .center-children { 2: text-align: ...
- java web工程发布以及解决tomcat闪退
1.tomcat闪退 a.环境变量错误 startup.bat最后假如PAUSE进入调试状态,双击startup.bat,可以看到错误,根据错误提示设置相应的环境变量,JAVA_HOME等. b.ec ...
- ScrollView详解
创建方式 1:StoryBoard/Xib 这里StoarBoard就不多说,直接拖就可以,说太多没意思,如果连这个都不会我只能先给你跪了! 2:代码: 1 2 3 CGRect bounds = [ ...
- ltt.js
var dailyBox = $('.daily-box-office'), curDate = new Date(), curYear = curDate.getFullYear(), curMon ...
- 【Stage3D学习笔记续】真正的3D世界(一):透视矩阵
如果各位看官跟着我的学习笔记一路看过来的话,一定会吐槽我的,这都是什么3D啊?从头到尾整个都是在使用GPU绘制一堆2D图像而已,的确,之前我们一直使用正交矩阵利用GPU加速来实现2D世界的展示,算不上 ...
- VB操作Excel
在工程中添加引用:Microsoft Office 9.0 Object Library Microsoft Excel 9.0 Object Library ...
- 一、FreeMarker 模版开发指南 第一章 入门
所有资料来自 南磊 翻译的官方文档,我弄简单了,适合自己以后拿出来翻看. 章节内容如下: 简介 模板+数据模型=输出 数据模型一览 模板一览 一.模板 + 数据模型 = 输出 输出结果: &l ...
- MapReduce的流程
1. Inputformat会从job的INPUT_DIR目录下读入待处理的文件,检查输入的有效性并将文件切分成InputSplit列表.Job实例可以通过setInputFormatClass(Cl ...
- 推荐eclipse velocity一款插件 --- veloeclipse
vm文件在eclipse展示很丑,关键字没有颜色之差.这里,推荐一款极其好用的velocity插件 -- veloeclipse 在 Eclipse 版本 4.5.0, 离线安装 Veloeclip ...