Get form elements by name?

前端 未结 1 545
醉酒成梦
醉酒成梦 2021-01-11 12:48

I would like to style all of the radio buttons with the same name in a form easily in a nice Prototype or jQuery-style shortcut.

$(\'billship\').select(\'name:

相关标签:
1条回答
  • 2021-01-11 13:07

    With jQuery:

    $('#billship input:radio[name="shipType"]');  
    $('input:radio[name="shipType"]', '#billship');
    

    Both are equivalent, but the 2nd one performs slightly better and I personally prefer it.

    With Prototype, I believe it would look like this:

    $$('#billship input[type="radio"][name="shipType"]');
    
    0 讨论(0)
提交回复
热议问题