获取自定义属性的值

Mee*_*eek 28 jquery radio-button attr

我有两个单选按钮.我希望能够获得已检查单选按钮的自定义属性"xmlvalue"的值.

我尝试过以下脚本:

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

标记:

<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
Run Code Online (Sandbox Code Playgroud)

在这里小提琴

- 但我一直得到"未定义".

有任何想法吗?

A. *_*lff 45

删除选择器的上下文:

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

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