我有一个文本框,从另一个文件使用ajax加载。在ajax.php中
<input type='text' id='ew' name='ew' value='0' class='ew' />在index.php中加载
<div id='ew1'></div>脚本是这样的
$(document).ready(function() {
$('input.ew').keyup(function(){
if(!isNaN(this.value) && this.value.length!=0){
var ew_ew = $(this).val();
alert(ew_ew);
}
});
});//ready但是我没有得到任何价值
发布于 2015-05-25 15:09:52
确认您已成功地将jQuery包含到页面中,然后尝试以下操作
$(document).ready(function() {
$('.ew').keyup(function(){
if(!isNaN($(this).val()) && $(this).val().length!=0){
var ew_ew = $(this).val();
alert(ew_ew);
}
});
});//ready发布于 2015-05-25 16:36:40
使用支持jquery on()函数的最新jquery
$(document).on('keyup','.ew',function(event){
value = $( this ).val();
if(!isNaN(value) && value.length!=0){
var ew_ew = value;
alert(ew_ew);
}
}); https://stackoverflow.com/questions/30412424
复制相似问题