Why can't I target the image element using jQuery

后端 未结 1 984
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-21 23:54

I am trying to add jQuery to work with my web site and this is my first excursion into jQuery. For some reason, I just can\'t get it to work and I am unsure of why. There ar

相关标签:
1条回答
  • 2020-12-22 00:06

    Remove # from id attribute of input

    Change

     <input type="file" id="#Image1">
    

    To

     <input type="file" id="Image1">
    

    OR

    Use \\ to escape #

     $("#\\#Image1").change(function () {
        alert("triggered");
     });
    

    Fiddle DEMO

    From Docs

    To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\.

    0 讨论(0)
提交回复
热议问题