bootstrap模态设置输入字段max属性的值

时间:2013-11-23 02:33:25

标签: twitter-bootstrap attributes modal-dialog max

我需要在bootstrap模式上设置输入类型max属性的max属性。我可以通过id属性来完成,但最多不能

代码:

  <!-- Modal -->
  <div class="modal fade" id="cartDialog" tabindex="-1" role="dialog" aria-labelledby="cartDialogLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h2 class="modal-title">Add to Cart</h2>
        </div>
        <form method="GET">
        <div class="modal-body">
          <h3>How many items would you like to order?</h3>
          <p><b>Inventory:</b> <input style="color:black" type="button" class="btn btn-link" id="inv" value=""> <b>Expected Delivery Date:</b> <?php echo $expecteddeldate ?></p>
          <p><b>Quantity:</b> <input style="width:50px" min="1" type="number" name="qty" value="1" required></p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
          <input type="hidden" name="p" value="<?php echo htmlspecialchars('add-cart') ?>">
          <input type="hidden" name="pid" id="pid" value="">
          <button type="submit" class="btn btn-primary">ADD TO CART</button>
        </div>
        </form>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
  </div><!-- /.modal --> 
<script type="text/javascript">
$(document).on("click", ".cartDialog", function () {
     var Inventory = $(this).data('inv');
       $(".modal-body #inv").val( Inventory );
     var pId = $(this).data('pid');
       $(".modal-footer #pid").val( pId );
});</script>

1 个答案:

答案 0 :(得分:0)

我使用.attr jquery属性出现了解决方案:

$('#mxv').attr( 'max', Inventory );

解决!