在html中动态更改分区

时间:2013-06-18 10:50:16

标签: javascript html css

我已经制作了一个代码,点击不同的链接,特定的部门分别改变。

第一个文件是: 的index.html

<div class="wrapper">       
    <div class="grid3 first">
        <ul class="categories">
            <li><a id="Engineering">Aerospace</a></li>
            <li><a id="Productive">Automotive</a></li>
            <li><a href="Chemicals">Chemicals</a></li>
        </ul>
    </div>
    <section id="neeraj_content">    
        <div class="grid19" id="Engineering" >
            <h2>Grow service revenue with world-class<br/>
            lifecycle service and support.</h2>
            <p>some displaying content here that appears in the division grid19 </p>
        </div>
    </section>
</div>

在这个索引文件中我有一个js

<script>
    $(document).ready(function(){
        $('#neeraj_menu ul li a').click(function(){
            $('#neeraj_content').load('division.html #' + $(this).attr('href'));
            return false;
        });
    });
</script>

现在我制作了另一个名为division.html的html文件,其中必须出现在分区grid19中的其他内容必须出现在该特定位置

        <div class="grid19" id="Engineering" >
            <h2>Grow service revenue with world-class<br/>
            lifecycle service and support.</h2>
            <p>some displaying content here that appears in the division grid19 </p>
        </div>
    </section>
</div>

        <div class="grid19" id="Productive" >
            <h2>Grow service revenue with world-class<br/>
            lifecycle service and support.</h2>
            <p>some displaying content here that appears in the division grid19 </p>
        </div>
    </section>
</div>

        <div class="grid19" id="Chemicals" >
            <h2>Grow service revenue with world-class<br/>
            lifecycle service and support.</h2>
            <p>some displaying content here that appears in the division grid19 </p>
        </div>
    </section>
</div>

现在点击生产或化学品,分部的内容必须改变。我在改变它时遇到了问题。它实际上访问division.html文件中的特定id。它不起作用。有问题。我无法得到错误的位置。 它也确实发生了变化,因为我之前已经厌倦了它并且它起作用了,现在我已经忘记了它是如何做的第一次。

1 个答案:

答案 0 :(得分:0)

您正在引用:

$('#neeraj_menu ul li a').click(function(){

但是你提供的html代码中没有出现id neeraj