dow56114
2014-01-20 04:30
浏览 64

无法从字段jquery mobile读取值

my html code

<?php 
  while($results = $user_class->fetch_array($sql)){
?>
  <input type="text" name="price[]" class="price" id="price" 
    size="5px" readonly value="<?php echo $results['price_v'] ?>">
  <select onChange="update(); return false;" name="qty[]" class="quant">
    <option value="0"></option>
    <?php 
      $limit = $results['limiter'];
      for($i=1;$i <= $limit;$i++ ){ 
    ?>
      <option value="<?php echo $i?>"><?php echo $i?></option>
    <?php } ?>
  </select>

this is my jquery code

$("#example_form tr.raww").each(function(i,o){ 
  if($(o).find(".quant").val()>0) { 
    total += $(o).find(".quant").val() * $(o).find(".price").val(); 
  } 
});

if i attach

<script type="text/javascript" src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js"></script>

My jQuery can't read the value from the field.
And if i remove that jquery mobile can read value from field.

http://jsfiddle.net/QJxYv/3/

Is there anything wrong with my jQuery code?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doushishi6513 2014-01-20 06:23
    已采纳

    Your code will work as long as there is only one element with class quant and one element with class price in each row of class raww.

    点赞 打赏 评论
  • doucong4535 2014-01-20 05:45

    Try the following:

         if ($(this).find("select.quant").val() > 0) {
    

    and

    sub_total += $(this).find("select.quant").val() * $(this).find(".price").val();
    

    Updated fiddle: http://jsfiddle.net/QJxYv/4/

    点赞 打赏 评论

相关推荐 更多相似问题