如何访问一个使用YUI检查单选按钮的价值? [英] How to access the value of a radio button that is checked using YUI?

查看:117
本文介绍了如何访问一个使用YUI检查单选按钮的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下单选按钮结构...

i have following radio button structure ...

<div id="test">
  <input name="test1" value="a" type="radio">
  <input name="test1" value="b" type="radio">
  <input name="test1" value="c" type="radio">
</div>

如何将我去有关检索任何检查单选按钮的价值?

how would i go about retrieving the value of any checked radio button?

我已经检查了YUI文档中的一个没有任何真正的好榜样。

i have checked the YUI documentation an there is not really any good example.

我也想知道如何获得通过输入名称元素YUI?

I would also like to know how to get the element by input name in YUI?

推荐答案

在YUI 3:

var value = Y.one("#test input[name=test1]:checked").get("value");

在YUI 2:

// the null, null, null, true is optional, but returns only the first match
var input = YAHOO.util.Dom.getElementsBy(function (el) {
                return (el.name === 'test1' && el.checked);
            }, 'input', 'test', null, null, null, true);

var value = input.value;

这篇关于如何访问一个使用YUI检查单选按钮的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆