从另一个javascript调用javascript onblur事件

时间:2014-08-22 20:56:08

标签: javascript onblur

这是我的javascript代码

$(document).ready(function() {
    var count = 0;

$("#add_btn").click(function(){
        count += 1;
    $('#container').append(
        '<table align="left" style="padding-left:120px; color:#6B1313; width:700px;" class="records">'
            +'<tr>'
                +'<td></td>'
                +'<td>Only Alphabet</td>'
                +'<td><input type="text" id="only_alphabet" name="only_alphabet" required ="required" onblur="number_validation()"/></td>'
            +'</tr>'
        +'</table>'
    );
});
});

但是我无法调用number_validation javascript函数,并且onblur事件没有像我预期的那样运行。那么有人可以帮我解决这个问题吗?感谢

1 个答案:

答案 0 :(得分:0)

var count = 0;

$(document).ready(function() {

$("#add_btn").click(function(){

        count += 1;

    $('#container').append(
        '<table align="left" style="padding-left:120px; color:#6B1313; width:700px;" class="records">'
            +'<tr>'
                +'<td></td>'
                +'<td>Only Alphabet</td>'
                +'<td><input type="text" id="only_alphabet" name="only_alphabet" required ="required"  /></td>'
            +'</tr>'
        +'</table>'
    );

   $('#only_alphabet').live('blur',function(){

  number_validation();

});

});



});