weixin_33724059 2014-03-03 15:18 采纳率: 0%
浏览 97

模态框似乎不起作用

Ok so I am trying to open abc.html file ( placed in same directory ) in modal box.

This is the code but it doesn't seem to work. Please help

<!DOCTYPE html> 
<html> 
<head>
    <script src="jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
   <script>
    $(document).ready(function(){
    $("a#someId").on("click", function(){
        $.post("abc.html", function(data){
    $("#myModalDiv").html(data).fadeIn();
    });
    });
});
 </script>
</head> 
<body>        
    <a id="someId" href="">This is a link to abc.html</a>
    <div id="myModalDiv">

    </div>
</body> 
</html>
  • 写回答

2条回答 默认 最新

  • weixin_33705053 2014-03-03 15:41
    关注

    Try to use e.preventDefault() here to prevent default action of your anchor:

    $(document).ready(function () {
        $("#someId").on("click", function (e) {
            e.preventDefault();
            $.post("abc.html", function (data) {
                $("#myModalDiv").html(data).fadeIn();
            });
        });
    });
    

    Also, because id is unique, you just need to use #someId instead of a#someId.

    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗