嘿,我正在尝试获取我制作的单击的自定义单选按钮的值。
这是按钮的js:
$("#df-opt0,#df-opt1,#df-opt2,#df-opt3,#df-opt4").click(function (input) {
$('#df-opt0').css("background-image", "url(img/radiobutton-OFF.png)");
$('#df-opt1').css("background-image", "url(img/radiobutton-OFF.png)");
$('#df-opt2').css("background-image", "url(img/radiobutton-OFF.png)");
$('#df-opt3').css("background-image", "url(img/radiobutton-OFF.png)");
$('#df-opt4').css("background-image", "url(img/radiobutton-OFF.png)");
//alert($(this).attr('id'));
$('#' + $(this).attr('id')).css("background-image", "url(img/radiobutton-ON.png)");
//globalRadioSelected = $(this).attr('id');
fValue = $(input).attr("store-id");
alert('the ID :'+fValue);
});
这是 HTML:
<div id="df-opt0" store-id="100"></div>
<div id="df-opt1" store-id="200"></div>
<div id="df-opt2" store-id="300"></div>
<div id="df-opt3" store-id="400"></div>
<div id="df-opt4" store-id="500"></div>
<div id="df-opt4txt" store-id="600">
<input type="text" id="df-opt4txt-txt" style="width: 130px;" class="formBoxes">
</div>
当我点击其中任何一个时,我得到的是:ID:未定义
我错过了什么?