Why can't I target the image element using jQuery

后端 未结 1 985
佛祖请我去吃肉
佛祖请我去吃肉 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

     
    

    To

     
    

    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)
提交回复
热议问题