-1

I have this code:

        $(".input_photo").click(function() {

            $.post("ajax/imagefile.html", function(img){
                complete: $(".bp_load").fadeIn(0).html(img);
            });
        });

Imagefile is a simple HTML page that contains the form and input type file with ID imageform.

And I have another code:

            $('#photoimg').live('change', function(){
                $("#imageform").ajaxForm({
                    target: '.preview'
                }).submit();
            });

I searched in the web, and I understand that live is deprecated, and I have changed to on, but it doesn't work. The input type file is changed, but the event doesn't triggered.

4

1 回答 1

3

相当于 live using .on()is: {delegate syntax}

$(document).on('change', '#photoimg',function(){
                $("#imageform").ajaxForm({
                    target: '.preview'
                }).submit();
            });
于 2013-06-13T08:33:31.393 回答