使用Jquery更改div中的内容

时间:2015-09-02 18:31:04

标签: javascript jquery

我已经完成了这一切设置和工作,但今天下午发生了一些变化,并且不能丢失。

基本上,jquery脚本根据侧边菜单中单击的链接更改#text_box的内容。单击时,脚本从information_database.html检索相关的href。

有谁知道缺少什么?

<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>

下面是一些链接样本:

 <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>

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>

1 个答案:

答案 0 :(得分:0)

控制台应该有错误。

时: (&#39; #text_box&#39;)。加载...

应该 $(&#39; #text_box&#39;)。加载...