jQuery Attribute selector with a period

前端 未结 4 929
一向
一向 2020-12-04 02:42

I\'m trying to use a jQuery selector that finds all input fields with a specific name:

$(\'input[name=Filter\']).click(function() {
    // do something
});
<         


        
相关标签:
4条回答
  • 2020-12-04 03:14

    Based on my comment to the question I can confirm that this does work...

    $('input[name="Parent.Filter"]').click(function() {
    });
    

    Working example here

    0 讨论(0)
  • 2020-12-04 03:27

    This works, you just need "" around the name:

    $('input[name="Parent.Filter"]').click(function() {
    });
    
    0 讨论(0)
  • 2020-12-04 03:35

    Use $("input[name='Parent.Filter']")

    0 讨论(0)
  • 2020-12-04 03:38

    Quotes are mandatory, and in this instance it won't work without them.

    $('input[name="Parent.Filter"]').click(function() {
    });
    

    From the API reference:

    value An attribute value. Quotes are mandatory.

    Here's a jsFiddle that demonstrates this.

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