I am trying to open a modal on click of a link. however, its not opening. Below is the code for the link:
<div class="span4" style="font-size: 14px">
<a href="#" onClick="openModal(); return false;" cssClass="view-more" >Some<br>textlater</a>
</div>
This is the code for the modal
<div class="modal hide fade" id="myDiv" style="width: 520px;display: block;border: 1px solid black">
<div class="modal-header" style="width: 517px;"><button type="button" class="close" data-dismiss="modal" aria-hidden="true" >×</button></div>
<div class="modal-body"">
<div id="mydiv1" style="text-align:center;">
<div class="span9"><img alt="img" style="margin-bottom: 10px;padding-top: 2px" src="./images/img.png"></div>
</div>
</div>
<div class="modal-footer">
<div class="button-bar-footer">
<div class="row">
<div class="pull-left">
<s:a href="#" cssClass="btn btn-link btn-back" data-dismiss="modal">
<span><s:text name="generic.cancel" /></span>
</s:a>
</div>
<div class="pull-right">
<button type="button" class="btn btn-success" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
This is the function
<script type="text/javascript">
function openModal(){
alert("hello");
$('myDiv').modal('show');
}
PLease guide where am i missing?
I found the issue.I was missing # before calling show modal. Below is the modified code
<script type="text/javascript">
function openModal(){
alert("hello");
$('#myDiv').modal('show');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.