jQuery .next()在FF中返回NULL但不在chrome中,即opera!

时间:2011-04-08 18:48:21

标签: jquery

我确实花了好几个小时试图解决这个问题,但是不能!与标题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>&nbsp;
         </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);
});

3 个答案:

答案 0 :(得分:1)

您是否尝试过正确使用<label>标记? http://www.w3schools.com/tags/tag_label.asp

答案 1 :(得分:0)

只需将div更改为span:

http://jsfiddle.net/rdyhE/4/

编辑:忘记更改结束标记

答案 2 :(得分:0)

如果您正在使用最新的jQuery,以及任何jQuery,那么您需要在引号中将name属性包装在选择器中:

$(document).ready(function() 
 {
    var fronts_price = parseFloat($('input[name="fronts"]:checked').next('.price-config').html());
    alert(fronts_price);
});