我在使用jquery向modal发送数据时遇到问题。我想在用户单击自述时显示详细信息。这是html代码:
<a id="readMore" class="george" href="" name="" data-toggle="modal" data-
target=".bs-example-modal-lg" data-id="(string)<?=$ourExpertiseTitle?>">Read More</a>
下面是脚本:
<script>
$(document).on('click',".george",function(){
var myourid = $(this).data('id');
$(".modal-body").val(myourid);
$('#mymodal').modal('show');
});
</script>
模式代码:
<div id="mymodal" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<div class="col-md-4">
<img class="img-fullwidth mt-15" alt="" src="images/team/avatar1.jpg">
</div>
<div class="col-md-8">
<h4 class="text-uppercase text-theme-colored font-weight-600 mt-0" id="bookId"><?=$ourExpertiseTitle?></h4>
<h6 class="text-gray font-13 font-weight-400 line-bottom"><?= $ourExpertiseSecondTitle ?></h6>
<p><?= $ourExpertiseDescriptionFull ?></p>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
因此,如何使用不同的ID将数据发送到modal。