开发者

can i load a document object inside another document object in jquery?

i have script like this....

<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <meta na开发者_如何学运维me="author" content="bbbbb" />
<script type="text/javascript" src="js/jquery-1.5.1.js"></script> 
    <title>for testing works</title>
<style>
div{

    height: 20px;
}

</style>
<script type="text/javascript">
$(document).ready(function() 
{ 
        $('div').click(function(){
           $(document).load('load.html');

        } );
});
</script>   
</head>

<body>
<div id="init"><a href="#init">Click Me</a></div>
<div id="div1"><a href="#div1">Div 1</a></div>
<div id="div2"><a href="#div2">Div 2</a></div>

</body>
</html>

in load.html i have a paragraph with with dummy content.

why this script is not changing my content of page... loading a document object inside other is allowed or not?


You should change $(document).load('load.html'); to $('body').load('load.html');:

$(document).ready(function() 
{ 
    $('div').click(function(){
        $('body').load('load.html');
        return false;
    });
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜