donglv9116
2017-02-22 06:47
浏览 35

使用Codeigniter在模态中使用jquery显示图像

How to show image in modal (#photoss), using jquery which id is called from :

 <div class=" top-deal">   
     <a data-toggle="modal" href="#" data-target="#tallModal" class="mask tt" ... photoss="<?php echo $rec->ss;?>" > 

This my script :

    <script type="text/javascript">
            $(document).ready(function(){

              $(".tt").click(function(){

                ....
                 $("#kabkota").html($(this).attr("kabkota"));

                 $('#photoss').html('<img src="'+base_url+'upload/screenshoot/'+ss+'" class="img-responsive">'); // show photo
                 });
               });
          </script> 

This my modal

    <div id="tallModal" class="modal modal-wide fade">
    <div class="modal-dialog">
     ....
         <h4 id='namaaplikasi'> Nama Aplikasi</h4> </br>
             <div id="photoss">

                </div>
            ...
  </div><!-- /.modal -->

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongzheng4556 2017-02-22 07:00
    已采纳

    You can show image in modal like this.

    Use anchor as:

    Remove data target attribute and use it as normal anchor as.

     <a href="javascript:;"  class="mask tt"  photoss="<?php echo $rec->ss;?>" > 
    

    Make the script like below:

     <script type="text/javascript">
    
                $(document).ready(function(){
    
                  $(document).on("click",".tt",function(){
    
                    var ss  =    $(this).attr("photoss");
                    var base_url = "your base url";
    
    
                     $('#photoss').html('<img src="'+base_url+'upload/screenshoot/'+ss+'" class="img-responsive">');
    
    
                     $("#tallModal").modal("show");
    
                   });
                 });   
              </script> 
    
    点赞 打赏 评论

相关推荐 更多相似问题