Bootstrap Modal不会关闭

use*_*179 1 javascript twitter-bootstrap

HTML:

<div id="im_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Image" aria-hidden="true">
    <div class="modal-footer">
        <a type="button" class="btn pull-left" href="javascript:close_preview()">Cancel</a>
        <button type="submit" class="btn btn-primary pull-left">OK</button>
Run Code Online (Sandbox Code Playgroud)

使用Javascript:

function close_preview() {
    $("#im_modal").modal("hide");
}
Run Code Online (Sandbox Code Playgroud)

正在调用函数close_preview,但不关闭模态.

PSL*_*PSL 5

它应该工作,可能功能的定位close_preview不是它应该的位置.但是有另一种方法可以不使用任何方法/事件,你可以data-dismiss为按钮添加属性.

<a type="button" class="btn pull-left" data-dismiss="modal">Cancel</a>
Run Code Online (Sandbox Code Playgroud)

小提琴