I need to pass the data attribute in my modal. to attach with image tag in src When clicked on the link. Below is my code. I am confused. I know we can use JavaScript onclick method to pass by reference. Still can anyone give me executable code. My code is below. I am not really good in making JavaScript functions.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" /> <a href="#checkImage" data-toggle="modal" data-myimage="imageNamefromDataBase.jpg"> Image </a> <div class="modal fade" id="checkImage" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" style="color:black;" id="myModalLabel">View Image</h4> </div> <div class="modal-body" style="color:black;"> <h1>Fee Submit</h1> <img src="#" alt="bank_chalan" id="thanks" /> </div> <div class="modal-footer"> <button type='submit' data-dismiss="modal" name='submit' class='btn btn-success'>Close</button> </div> </div> </div> </div>