2013-11-23 85 views
0

我需要在引導模式上設置輸入類型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> 

回答

0

我使用.attr jQuery的出來的解決方案屬性是這樣的:

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

解決了!