mah*_*ich 11 javascript yui input button radio
我有以下单选按钮结构...
<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>
Run Code Online (Sandbox Code Playgroud)
我将如何检索任何已检查的单选按钮的值?
我检查了YUI文档,没有任何好的例子.
我还想知道如何在YUI中通过输入名称获取元素?
Luk*_*uke 14
在YUI 3中:
var value = Y.one("#test input[name=test1]:checked").get("value");
Run Code Online (Sandbox Code Playgroud)
在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;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4649 次 |
| 最近记录: |