Javascript 从表单中获取数据并在引导模式中显示它们

Javascript 从表单中获取数据并在引导模式中显示它们,javascript,jquery,Javascript,Jquery,我有一些行,每个行都附加了数据属性。当我单击每个表行时,我希望将数据属性发送到另一个表单,并在模式中显示该表单 卡马尔 乱数假文 $20 价格∕一晚 容量: x2 书 预订 接近 我试过这个()但不起作用 $('#fileInfo tr td').on('click', function(){ var data = $(this).closest('tr').attr('data-name'); $('#modalInfo').modal('sho

我有一些行,每个行都附加了数据属性。当我单击每个表行时,我希望将数据属性发送到另一个表单,并在模式中显示该表单


卡马尔
乱数假文
$20
价格∕一晚
容量:
x2

预订 接近
我试过这个()但不起作用

    $('#fileInfo tr td').on('click', function(){
        var data = $(this).closest('tr').attr('data-name');
        $('#modalInfo').modal('show');
        $('#modalInfo').find(".filename").html(data);;
    });
data toggle=“modal”data target=“#modalInfo”从表元素中删除此项


data toggle=“modal”data target=“#modalInfo”将其从表元素中删除

您可以这样做。它起作用了


你可以这样做。它起作用了

<div class="col-md-12">
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>Your ID</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <tr id="modal-1">
                <td>Modal Title 1</td>
                <td class="text-right"><button class="btn btn-danger btn-xs" data-id="1" data-title="Modal Title 1" id="check">x</button></td>
            </tr>
            <tr id="modal-2">
                <td>Modal Title 2</td>
                <td class="text-right"><button class="btn btn-danger btn-xs" data-id="2" data-title="Modal Title 2" id="check">x</button></td>
            </tr>
        </tbody>
    </table>
</div>
<div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal" type="button">&times;</button>
                <h4 class="modal-title">Modal by ID</h4>
            </div>
            <div class="modal-body">
                <p id="content"></p>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal" type="button">CANCEL</button>
            </div>
        </div>
    </div>
</div>
$('button#check').on('click', function(e) {
    e.preventDefault();
    var id = $(this).data('id');
    $('#myModal').data('id', id).modal('show');
      $("#content").html($(this).data("title"));
});