开发者

Custom div loading not working

开发者 https://www.devze.com 2022-12-20 10:20 出处:网络
To those jQuery experts out there.I have the following markup and code: <html> <head> <title>Test Framework</title>

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

精彩评论

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