dqvs45976 2018-05-03 08:35
浏览 49
已采纳

将数据发送到jquery以模态显示

I have a problem with sending data to modal using jquery I want to show the details when the user clicks on readme this is the html code:

<a id="readMore"  class="george" href="" name="" data-toggle="modal"  data-
target=".bs-example-modal-lg" data-id="(string)<?=$ourExpertiseTitle?>">Read More</a>

and this is script:

 <script>
      $(document).on('click',".george",function(){
           var myourid = $(this).data('id');
           $(".modal-body").val(myourid);
           $('#mymodal').modal('show');
      });
</script>

modal code:

 <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">&times;</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>

so how can I send data to modal with different ids.

  • 写回答

1条回答 默认 最新

  • du1462 2018-05-04 18:16
    关注

    Use $("#bookId").val(myourid); instead of $(".modal-body").val(myourid);

    This will set the ID at your h4 element on the modal.

    To show the "Second Title" and "Full Description" you'll need to retrieve the data using AJAX.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大