小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

利用JQuery的load函數(shù)動態(tài)加載頁面 - Master HaKu - 博客園

 悟靜 2011-05-15
JQuery有好多Ajax函數(shù),其中l(wèi)oad是用來動態(tài)加載一個頁面的內(nèi)容到指定的dom元素上。

我們來做個例子:
做一個上下(左右)結(jié)構(gòu)的頁面,其中下左部分放2個以前我們做過的div按鈕,下右部分則為動態(tài)加載內(nèi)容。
按每個按鈕,加載該按鈕相應(yīng)的網(wǎng)頁內(nèi)容到下右區(qū)域。

基本語法為:
$('#區(qū)域id').load('頁面名稱');

完整的網(wǎng)頁代碼如下:
<html xmlns="http://www./1999/xhtml" >
<head runat="server">
    
<title>JQuery - Load</title>
    
<link rel="stylesheet" media="all" type="text/css" href="../CSS/myStyle.css" />
    
<script type="text/javascript" src="../JsLib/jquery-1.3.2.min.js"></script>//必須,且在某目錄下要存在
    
<script type="text/javascript" src="../JS/basicEffect.js"></script>//必須,且在某目錄下要存在
    
<style type="text/css">
        #header 
{
          margin-bottom
: 1em;
          padding-bottom
: 1em;
          border-bottom
: 1px solid #eee;
        
}
        .buttonListArea 
{
          float
: left;
          width
: 150px;
          padding-right
: 10px;
          border-right
: 1px solid #eee;      
          margin-right
: 10px;
        
}
        .buttonArea 
{
          margin
: 10px;
          padding-bottom
:20px;
        
}
        #load_content 
{
          float
: left;
          width
: 550px;
          text-align
:center;
        
}
    
</style>
    
<script type="text/javascript">
        $(document).ready(
function() {
            $(
'#btnLoad1.button').click(function() {
                $(
'#load_content').load('loadContent1.htm');
            });
            $(
'#btnLoad2.button').click(function() {
                $(
'#load_content').load('loadContent2.htm');
            });
        });
    
</script>
</head>
<body>

<form id="form1" runat="server">

<div id="container">

    
<div id="header">
        
<h2>JQuery Load Example</h2>
    
</div>

    
<div class="buttonListArea">
        
<div class="buttonArea">
            
<div class="button" id="btnLoad1">Load 1</div>
        
</div>
        
        
<div class="buttonArea">
            
<div class="button" id="btnLoad2">Load 2</div>
        
</div>
    
</div>
    
    
<div id="load_content">
        
<h2>這是要被加載的區(qū)域</h2>
    
</div>

</div>

</form>

</body>
</html>

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多