简体   繁体   中英

Using Jquery to change content in a div

I had this all setup and working but something has changed this afternoon and can't place whats missing.

Basically the jquery script changes the contents of #text_box according to the link that is clicked in the side menu. When clicked the script retrieved the related href from information_database.html.

Does anyone know what is missing?

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

    $('#accordion ul li a').click(function(){
                ('#text_box').load('information_database.html #' + $(this).attr('href'));
                    return false;
    });     
    }); 
</script>

Heres a sample of the links:

 <div id="container">
            <div id="side_bar">
            <div id="accordion">
            <h1 class="blue white_text"><img src="ear_square.png">Ear</h1>
            <div><ul class="blue">
            <li><a href="glue_ear">Glue ear / Adenoidectomy</a></li>
            <li><a href="meatoplasty">Meatoplasty</a></li>
            <li><a href="canalplasty">Canalplasty</a></li>
            <li><a href="cholesteatoma">Cholesteatoma</a></li>
            <li><a href="ossiculoplasty">Ossiculoplasty</a></li>
            <li><a href="myringoplasty">Myringoplasty</a></li>
            <li><a href="otosclerosis">Otosclerosis</a></li>
            </ul></div>
</div>
</div>
</div>

And a sample of the data in the information_database.html:

<div id="meatoplasty">
<h1 class="blue_text">Meatoplasty</h1>

<p>This is an operation to widen the opening of your ear canal. It may be performed as a procedure by itself, but more often it is performed as a part of ear surgery for other conditions. The opening of the ear canal (meatus) is formed mainly of cartilage and skin at its most outer part. If this is narrow, this may result in wax blockage, outer ear infections, difficulty wearing hearing aids and difficulty in examining or treating your ear in the outpatient clinic. 
</div>

There should be an error in the console.

Is: ('#text_box').load ...

Should $('#text_box').load ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM