实时监听输入框值变化
首先创建Jquery.fn扩展
jQuery.fn.extend({
inputChange: function(callback){
if($.support.leadingWhitespace){
//if($.browser.msie){
this.bind('propertychange', function(e){
if(e.originalEvent.propertyName == 'value'){
$(this).keyup();
}
});
this.bind('keyup', callback);
}else{
this.bind('input', callback);
}
return( this );
}
});
调用方法:
$('.input').inputChange(function(){
console.log($(this).val());
});
获取select值
$("#selectID option:selected").text()