Why is my jquery input mask not working?

前端 未结 3 1655
失恋的感觉
失恋的感觉 2021-01-22 19:56

I am trying to use the jQuery input mask plug-in (jquery.maskedinput-1.3.min.js), and I have searched for several examples/solutions, and my code is exactly as other working exa

相关标签:
3条回答
  • 2021-01-22 20:23

    remove the space from the ID and then try this

    jQuery(function ($) {
        $("#POIName").mask("99/99/9999");
    });
    
    0 讨论(0)
  • 2021-01-22 20:27

    jQuery selectors follow the standard CSS syntax, so the space in the middle of your ID is actually being treated as a descendant selector. Make your life easier: when dealing with jQuery, keep your IDs and classes limited to alphanumerics, hyphen and that's about it.

    To clarify: there is a quote/escape syntax in jQuery, but IMHO it's too annoying to deal with, hence I'm not even giving an example of it.

    0 讨论(0)
  • 2021-01-22 20:39

    Spaces are not valid in ID attributes. You should change your id to $("#POIName") and update your html as well.

    Jquery-ids-with-spaces is a similar question that you may find intersting.

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