Skip to content Skip to sidebar Skip to footer

Need To Load Image As Modal On Click In Bootstrap Css

I have tried loading a modal image on clicking a image by fading the background. It works for me. But for multiple images how can I load the image which I have clicked based on the

Solution 1:

Try this

HTML

<!-- Image trigger modal --><imgsrc="http://sheshtawy.files.wordpress.com/2010/05/extra-firefox.png"class="img-responsive img-thumbnail"style="min-height:300px;height:300px;"alt="Responsive image"><imgsrc="http://sheshtawy.files.wordpress.com/2013/03/cairo_pollution.jpg?w=250"/><imgsrc="http://sheshtawy.files.wordpress.com/2012/12/img_4749.jpg?w=250"/><!-- Modal --><divclass="modal fade"id="myModal"tabindex="-1"role="dialog"aria-labelledby="myModalLabel"aria-hidden="true"><divclass="modal-dialog"><divclass="modal-content"><divclass="modal-header"><buttontype="button"class="close"data-dismiss="modal"aria-hidden="true">&times;</button><h4class="modal-title"id="myModalLabel">Modal title</h4></div><divclass="modal-body"><imgid="mimg"src=""></div></div><!-- /.modal-content --></div><!-- /.modal-dialog --></div><!-- /.modal -->

Script

$(window).load(function(){
    $('img').on('click',function()
                {
                    var sr=$(this).attr('src'); 
                    $('#mimg').attr('src',sr);
                    $('#myModal').modal('show');
                });
});

DEMO

Post a Comment for "Need To Load Image As Modal On Click In Bootstrap Css"