简体   繁体   English

多次对动态内容使用相同的模式代码

[英]Use the same modal codes multiple times with dynamic content

I have the following modal in my HTML 我的HTML中有以下模式

 <div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalCenterTitle">-----</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <div class="modal-body"> ---- </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">ശരി</button> </div> </div> </div> </div> 

I am triggering this modal using the following php-javascript combination based on the condition $resultCheck > 0 我根据条件$resultCheck > 0使用以下php-javascript组合触发此模式

 if($resultCheck > 0){ echo '<script> $("#exampleModalCenter").modal("show"); </script>'; } 

What I need 我需要的

I need to use the same modal exampleModalCenter for different conditions Eg: $resultCheck = 0 and so on with title and content changes according to the conditions. 我需要使用相同的模式exampleModalCenter条件不同,如: $resultCheck = 0根据条件与标题和内容的变化等。 Does anyone know how to do it? 有人知道怎么做吗?

Yes, it is possible to use. 是的,可以使用。 You can change the Title and content based on the condition which triggers the modal. 您可以根据触发模态的条件来更改标题和内容。

For this utilize, 为此,

  $('#exampleModalCenterTitle').text('The replaced text.');

And you can do the same with the other contents. 您可以对其他内容执行相同的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM