开发者

Custom div loading not working

To those jQuery experts out there. I have the following markup and code:

<html>
<head>
<title>Test Framework</title>
<script src="js/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).开发者_如何学运维ready(function(){   
    $('.nav').click(function(e) {
        e.PreventDefault();
        var id = $(this).attr('id');
        var path = "views/" + id + ".html";
        $("#main").load(path); 
    });
});
</script>
</head>
<body>
<div id="links">
    <a class="nav" id="test" href="javascript:void(0);">Test Page</a>
</div>
<div id="main">

</div>
</body>
</html>

My nav class fires when I click the link, but fails to get past the PreventDefault method. The class fires, but nothing loads into my div. The page is definately there. Any ideas why this wouldn't be working?


The problem may be with your call to preventDefault:

$(document).ready(function(){   
    $('.nav').click(function(e) {
        e.preventDefault();
        var id = $(this).attr('id');
        var path = "views/" + id + ".html";
        $("#main").load(path); 
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜