簡體   English   中英

動態更改html中的除法

[英]dynamically changing divisions in html

我已經編寫了一個代碼,單擊不同的鏈接后,特定的分區將分別更改。

第一個文件是: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文件,其中必須出現在除法格網19中的其他內容必須顯示在該特定位置上

        <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。 它不起作用。 有問題。 我無法找到錯誤所在。 而且它的確發生了變化,因為我早先已經厭倦了它並且起作用了,現在我忘記了它是如何第一次做的。

您正在引用:

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

但在您提供ID的HTML代碼中neeraj不會出現

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM