获取自定义属性的值 [英] Get value of custom attribute

查看:116
本文介绍了获取自定义属性的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个单选按钮.我希望能够获取选中的单选按钮的自定义属性"xmlvalue"的值.

I have two radio buttons. I would like to be able to get the value of the custom attribute "xmlvalue" of the checked radio button.

我尝试使用以下脚本:

var userType = $("input[name=ctrl_CustomerType]:checked", this).attr('xmlvalue');

标记:

<input type="radio" name="ctrl_CustomerType" id="ctrl_CustomerType_1" xmltag="CustomerType" xmlvalue="existingCustomer" checked="checked"> Yes
<br />
<input type="radio" name="ctrl_CustomerType" id="ctrl_CustomerType_2" xmltag="CustomerType" xmlvalue="newCustomer"> No

在这里拨弄

-但是我不断收到未定义".

-- But I keep getting "Undefined".

有什么想法吗?

推荐答案

删除选择器的上下文:

http://jsfiddle.net/NrQek/1/

 var userType = $("input[name=ctrl_CustomerType]:checked").attr('xmlvalue');
        alert("xmlvalue is: " + userType);

这篇关于获取自定义属性的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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