大家好,我希望使用以下代码捕获标签名称(72*30):
$("input[type = 'radio']:checked:last").each(function() {
var idVal = $(this).attr("id");
var a = $("label[for='"+idVal+"']").text();
alert(a);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li class="radio">
<input class="tmcp-field nav nav-pills dimension-layer-dimension tm-epo-field tmcp-radio" type="radio">
<label id="tmcp_radio_9" >72*30</label>
<span class="price tc-price hidden">
<span class="amount">20 <i class="fa fa-inr"></i></span>
</span>
</li>
但是代码没有弹出任何 alert
。有什么问题吗?