Jquery keyup事件在Bootstrap Modal中不起作用

时间:2015-11-09 17:15:37

标签: jquery twitter-bootstrap-3 bootstrap-modal onkeyup

您好我无法使用keyup事件获取我的jquery总和以在Bootstarp 3 Modal中工作。不在模态中时它工作正常。模态是链接到从MySQL填充的员工列表。任何人都可以帮忙!

var fi = $(this)[0].files;
LoadImages(fi).then(function(status) {
  // use status here.
});

链接到模态

<script type="text/javascript">
$(document).ready(function () {
    $("#amount, #exp, #unit_price, #taxit").on('keyup',function(event){
        var amount =  $("#amount").val() - jQuery("#exp").val();;
        var subtotal =   amount;
        var total = subtotal - (subtotal  * $("#tax").val() / 100);
        var taxpaid = subtotal  * $("#tax").val() / 100;
        $("#unit_price").val(amount);
        $("#taxpaida").val(taxpaid);
        $("#total").val(total);
    });
});
</script>  

Bootstrap Modal

<!--link fro  mysql  Modal -->
<a data-toggle="modal" href="#cispayment<?php echo $row['empId']; ?>">
     <i class="fa fa-edit text-info" data-toggle="tooltip" data-placement="left" title="<?php echo $viewEmpTooltip; ?>"></i>
</a>

解决

<!-- Modal -->
<div class="modal fade" id="cispayment<?php echo $row['empId']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">New CIS Payment</h4>
            </div>
            <div class="modal-body">
                 <div class="col-md-12"> 
                    <p class="lead"><?php echo 'CIS Payment for '.clean($row['theEmp']); ?>?</p>
                </div>  
                <label for="unitcost">Unitcost</label>
                <input type="text" id="amount" />
                <input type="text" id="exp" />
                <input type="text" id="unit_price" />
                <label for="quantity">Quantity</label>
                <input type="text" id="quantity" />
                <label for="tax">Tax</label>
                <input type="text" id="taxit" />
                <label for="tax">Tax</label>
                <input type="text" id="taxpaida" />
                <label for="total">Total</label>
                <input type="text" id="total" />
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save changes</button>
            </div>
        </div>
    </div>
</div>

0 个答案:

没有答案