Whether the repeated use of the trigger () function will slow down the code, or other adverse effects.

problem description

()
trigger()
trigger()..

the environmental background of the problems and what methods you have tried

emm,

related codes

/ / Please paste the code text below (do not replace the code with pictures)

    // HTML
    <form action="{:url("index/User/userImg")}" enctype="multipart/form-data" method="post" style="display:none;">
      <input type="file" name="image" /> <br>
      <input type="submit" name="upImg" value="" />
    </form>
    // 
    $(".userImg").click(function(){
        $("input[name="image"]").trigger("click");
        $("input[name="image"]").change(function () {
            var img = $(this).val();
            if (img != "") {
                $("input[name="upImg"]").trigger("click");
            }
        })
    })

what result do you expect? What is the error message actually seen?

is, trigger () necessary in my project? if not, how can I modify the code? Or make valuable suggestions. Please don"t talk about using plug-ins, but you still want to exercise your hands-on skills. Thank you.)

Apr.03,2021

performance may have an impact, because you need to execute the corresponding method of the click event directly, but now you trigger the click event directly and then execute the corresponding method indirectly. But in my opinion, the impact may be relatively small. Performance may not be intuitive. The best way is to call the method corresponding to the event. If you don't have this program, call the submit method of form

.
$('form').submit()
Menu