jquery 监听input输入值改变方法
2017-03-22 17:59
411 查看
1.JQuery
$(
'#username'
).bind(
'input propertychange'
,
function
() {
$(
'#content'
).html($(
this
).val().length +
' characters'
);
});2.JAVAScript(1)oninput标准HTML5事件 比onchange好用,兼容性还可以(2)onchange事件,这个就不多说了
oninput 事件在 IE9 以下版本不支持,需要使用 IE 特有的 onpropertychange 事件替代,
在监听到 onpropertychange 事件后,可以使用 event 的 propertyName 属性来获取发生变化的属性名称。集合 oninput & onpropertychange 监听输入框内容变化的示例代码如下:<head><script type="text/javascript">// Firefox,Google Chrome,Opera,Safari,Internet Explorer from version 9function OnInput (event) {alert ("The new content: " + event.target.value);}// IEfunction OnPropChanged (event) {if (event.propertyName.toLowerCase () == "value") {alert ("The new content: " + event.srcElement.value);}}</script></head><body>Please modify the contents of the text field.<input type="text" oninput="OnInput (event)" onpropertychange="OnPropChanged (event)" value="Text field" /></body>$('#username').bind('input propertychange',function() {$('#content').html($(this).val().length +' characters');});
相关文章推荐
- js与jquery实时监听输入框值的oninput与onpropertychange方法
- js与jquery实时监听输入框值的oninput与onpropertychange方法
- js与jquery实时监听输入框值的oninput与onpropertychange方法
- js与jquery实时监听输入框值的oninput与onpropertychange方法
- js与jquery实时监听输入框值的oninput与onpropertychange方法
- js与jquery实时监听输入框值的oninput与onpropertychange方法
- js与jquery实时监听输入框值的oninput与onpropertychange方法
- jquery的validate检验,提示在input后面,输入一次改变一次class
- jquery 监听input输入值事件
- js与jquery实时监听输入框值变化方法
- jquery 自定义input输入监听事件
- js/jquery 实时监听输入框值变化的完美方案:oninput & onpropertychange
- js/jquery 实时监听输入框值变化的完美方案:oninput & onpropertychange
- jquery 改变 输入框 input 的值 动态监听值改变
- 使用jQuery监听扫码枪输入并禁止手动输入的实现方法
- js/jquery 实时监听输入框值变化的完美方案:oninput & onpropertychange
- jquery监听input元素输入
- ff下JQuery无法监听input的keyup事件的解决方法
- js/jquery 实时监听输入框值:oninput & onpropertychange
- js与jquery实时监听输入框值的oninput与onpropertychange方法