0

好的,希望我能有效地解释这一点,所以就到这里。

我有一个无序列表,其中每个列表项通过我的“服务”页面上的 jquery 将 html 页面加载到 div 中。

基本上在首页我有几个链接,当单击一个时,我需要它转到“服务”并在 div 中查看相应的 html 页面。

代码是这样的:

服务页面:

<ul id="service-nav">

            <li><a id="interlocking" href="#">Interlocking</a></li>
            <li><a id="pool-backfill" href="#">Pool Backfill</a></li>
            <li><a id="poured-concrete" href="#">Poured Concrete</a></li>
            <li><a id="parging" href="#">Parging</a></li>
            <li><a id="custom-land" href="#">Custom Landscaping</a></li>
            <li><a id="snow-rem" href="#">Snow Removal</a></li>
            <li><a id="excavation" href="#">Excavation</a></li></ul>
      </ul>

    <div id="right-area"> <!-- This is where we load the relevant html's -->
    </div>

首页:

        <ul>
            <li><a href="services.php?token=interlocking">Interlocking</a></li>
            <li><a href="services.php?token=pool-backfill">Pool Backfill</a></li>
            <li><a href="services.php?token=poured-concrete">Poured Concrete</a></li>
        </ul>

这是我的 jQuery 供您参考:

<script type="text/javascript">
$(document).ready(function() {

    $(function(){ 
        var token = window.location.toString().split("=")[1]; 

        $("#" + token).click(); 

        });​


    $('#interlocking').click(function() {
        $('#right-area').load('http://romanstonedesigns.com/new/services/interlocking.php', function() {
        });
    });

    $('#pool-backfill').click(function() {
        $('#right-area').load('http://romanstonedesigns.com/new/services/pool-backfill.php', function() {
        });
    });

    $('#poured-concrete').click(function() {
        $('#right-area').load('http://romanstonedesigns.com/new/services/poured-concrete.php', function() {
        });
    });

    $('#parging').click(function() {
        $('#right-area').load('http://romanstonedesigns.com/new/services/parging.php', function() {
        });
    });

    $('#custom-land').click(function() {
        $('#right-area').load('http://romanstonedesigns.com/new/services/custom-landscaping.php', function() {
        });
    });

    $('#excavation').click(function() {
        $('#right-area').load('http://romanstonedesigns.com/new/services/excavation.php', function() {
        });
    });

    $('#snow-rem').click(function() {
        $('#right-area').load('http://romanstonedesigns.com/new/services/snow-removal.php', function() {
        });
    });







});

</script>
4

1 回答 1

0

好的,假设我们要显示联锁页面,那么您的首页应该是这样的:

1.

<ul>
        <li><a href="services.php?token=Interlocking">Interlocking</a></li>
    </ul>

2.在您的服务页面中,jquery代码应该是:

  <script type="text/javascript">


$(function(){ 




    $('#interlocking').click(function() {
    $('#right-area').load('http://romanstonedesigns.com/new/services/interlocking.php', function() {
    });
});

$('#pool-backfill').click(function() {
    $('#right-area').load('http://romanstonedesigns.com/new/services/pool-backfill.php', function() {
    });
});

$('#poured-concrete').click(function() {
    $('#right-area').load('http://romanstonedesigns.com/new/services/poured-concrete.php', function() {
    });
});

$('#parging').click(function() {
    $('#right-area').load('http://romanstonedesigns.com/new/services/parging.php', function() {
    });
});

$('#custom-land').click(function() {
    $('#right-area').load('http://romanstonedesigns.com/new/services/custom-landscaping.php', function() {
    });
});

$('#excavation').click(function() {
    $('#right-area').load('http://romanstonedesigns.com/new/services/excavation.php', function() {
    });
});

$('#snow-rem').click(function() {
    $('#right-area').load('http://romanstonedesigns.com/new/services/snow-removal.php', function() {
    });
});

    var token = window.location.toString().split("=")[1]; 
    $("#" + token).click(); 

    });

再见!

于 2012-04-08T01:46:21.690 回答