我确实花了好几个小时试图解决这个问题,但是不能!与标题sais一样,以下代码适用于除Firefox之外的所有内容!
HTML
<div class="bottom">
<fieldset>
<ul>
<li>
<label>
<input type="radio" name="fronts" class="config-inp-cha" value="1" checked="checked" />
Buckets w/ adj headrests
($<div class="price-config">179.97</div>)
</label>
</li>
</ul>
</fieldset>
</div><!--bottom-->
JavaScript描述:非常简单,我在引用checked值时抓取price-config div的值。这在Firefox中返回NaN,但在其他所有浏览器中都可以使用! PLzzz帮助
$(document).ready(function()
{
var fronts_price = parseFloat($("input[name=fronts]:checked").next('.price-config').html());
alert(fronts_price);
});
答案 0 :(得分:1)
您是否尝试过正确使用<label>
标记?
http://www.w3schools.com/tags/tag_label.asp
答案 1 :(得分:0)
答案 2 :(得分:0)
如果您正在使用最新的jQuery,以及任何jQuery,那么您需要在引号中将name属性包装在选择器中:
$(document).ready(function()
{
var fronts_price = parseFloat($('input[name="fronts"]:checked').next('.price-config').html());
alert(fronts_price);
});