Skip to content

Instantly share code, notes, and snippets.

@vincenting
Last active December 23, 2015 19:39
Show Gist options
  • Save vincenting/6684038 to your computer and use it in GitHub Desktop.
Save vincenting/6684038 to your computer and use it in GitHub Desktop.
兼容性的解决浏览器的input变化
$('textarea').bind('input', function() {
$('.msg').html($(this).val().length + ' characters');
});
if($('textarea')[0].attachEvent){
$('textarea')[0].attachEvent('onpropertychange', function(ev){
if(ev.propertyName.toLowerCase() === 'value') {
$('textarea').trigger('input')
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment