本文介绍了按名称获取表单元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用一个很好的Prototype或jQuery风格的快捷方式轻松地将所有具有相同名称的单选按钮样式化。
$('billship')。select('name:shipType')
或类似的东西。
字段名称是否存在?
解决方案
使用jQuery:
$('#billship input:radio [name =shipType]');
$('input:radio [name =shipType]','#billship');
两者相同,但第二个表现稍好,我个人更喜欢它。
使用Prototype,我认为它看起来像这样:
$$(' #billship input [type =radio] [name =shipType]');
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:shipType')
or something like that.
Does such a shortcut for form field names exist?
解决方案
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"]');
这篇关于按名称获取表单元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!