Skip to content

input 输入框输入时实时监听并且触发相应动作 #7

@milixie

Description

@milixie
  • 使用原生的:
function onInput(event) {
	console.log(event.target.value)
}
//兼容 ie
function onPropChange(event) {
	if (event.propertyName.toLowerCase () == "value") {
		console.log(event.srcElement.value);
	}
}
//html 里面
<input type="text" oninput="onInput(event)" onpropertychange="onPropchange(event)" />
  • 使用 jQuery:
$('.wrap').bind('input propertychange', function(){
  console.log('1111');
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions