Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
milixie opened this issue Dec 14, 2016 · 0 comments
Open

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

milixie opened this issue Dec 14, 2016 · 0 comments

Comments

@milixie
Copy link
Owner

milixie commented Dec 14, 2016

  • 使用原生的:
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');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant