我想点击一个链接打开一个模态。然而,它没有开放。以下是链接的代码:
<div class="span4" style="font-size: 14px">
<a href="#" onClick="openModal(); return false;" cssClass="view-more" >Some<br>textlater</a>
</div>
这是模态的代码
<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>
这是功能
<script type="text/javascript">
function openModal(){
alert("hello");
$('myDiv').modal('show');
}
PLease指南哪里缺少?
答案 0 :(得分:0)
我发现了这个问题。在调用show modal之前我错过了#。以下是修改后的代码
<script type="text/javascript">
function openModal(){
alert("hello");
$('#myDiv').modal('show');
}