2014-01-20 04:30
浏览 64

无法从字段jquery mobile读取值

my html code

  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>
      $limit = $results['limiter'];
      for($i=1;$i <= $limit;$i++ ){ 
      <option value="<?php echo $i?>"><?php echo $i?></option>
    <?php } ?>

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=""></script>

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

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) {


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

    Updated fiddle:

    点赞 打赏 评论

相关推荐 更多相似问题