1

誰かが助けることができれば。私は自分のページをhtmlとcssで開発しています。今、私はスクロールしてあなたが望むものを手に入れるのに長くて退屈になったこのページを持っています. :targetcss でタグを使用してページをセクションに分割しましたが、一部のブラウザーでは機能しません。私はjavascriptで遊んでいますが、成功していません。誰かがページをロードしたときに目次として機能する内部リンクのみを表示し、ユーザーが内部リンクをクリックしたときにそのセクションのみが表示されるように、ページで使用する必要があるjsスクリプトを誰かが助けてくれますか? divの表示またはポップアップにリンクされていますか?

または、代わりに PHP を使用する方法はありますか?

 <div>
            <ul>
            <li><a href="#introduction">Introduction to 
antimicrobials</a></li>
            <li><a href="#antifungals">Antifungal Drugs</a></li>
            <li><a href="#antiprotozoals">Antiprotozoal Drugs</a></li>
            <li><a href="#antihelminthics">Antihelminthic Drugs</a></li>
            <li><a href="#antibacterials">Antibacterials</a></li>
            <li><a href="#aminoglycosides">Aminoglycosides</a></li>
            <li><a href="#antifolates">Antifolate Drugs</a></li>
            <li><a href="#fluoroquinolones">Fluoroquinolones</a></li>
            <li><a href="#antimycobacterials">Antimycobacterial 
Drugs</a></li>            

            </ul>

            <div id="introduction">
            Viruses: Smallest pathogens, programmed to infect only certain 
body cells. Virus uses a body cells to reproduce itself it cannot be 
treated with medication.

Bacteria: single celled microorganism, 1000 different bacteria, but 100 
cause disease.
- Bacteria can be treated with antibiotics.
- Some bacteria are becoming immune to certain antibiotics.
- Bacterial Diseases: Strep throat, Tuberculosis Gonorrhea, Syphilis

Fungi: single celled or multicellular plantlike organism
- Fungi can cause diseases of the skin, mucous membrane, and lungs.
- Fungi Diseases: Athlete’s foot, Ringworm, Jock itch, Nail infections, 
Candidiasis</div>



<div id="antifungals">
Amphotericin B continues to be an important drug for the treatment of 
systemic fungal infections. However, several azoles and echinocandins are 
proving to be just as effective in some systemic mycoses with less risk of 
toxic effects.
</div>


<div id="antiprotozoals">
Drugs for Malaria:

Malaria is one of the most common diseases worldwide and a leading cause of 
death. Plasmodium species that infect humans (P falciparum, P malariae, P 
ovale, P vivax) undergo a primary developmental stage in the liver and then 
parasitize erythrocytes. P falciparum and P malariae have only 1 cycle of 
liver cell invasion. The other species have a dormant hepatic stage 
responsible for recurrent infections and relapses. Primary tissue 
schizonticides (eg, primaquine) kill schizonts in the liver, whereas blood 
schizonticides (eg, chloroquine, quinine) kill these parasitic forms only 
in the erythrocyte. Sporonticides (proguanil, pyrimethamine) prevent 
sporogony and multiplication in the mosquito.

Drugs: Chloroquine, Quinine, Mefloquine, Primaquine, pyrimethamine, 
proguanil, Sulfadoxine, Dapsone, Doxycycline, Amodiaquine, Atovaquone, 
Halofantrine, Artesunate, Artemether, Dihydroartemisinin

</div>

<div id="antihelminthics">
Antihelminthic drugs have diverse chemical structures, mechanisms of 
action, and properties. Most were discovered by empiric screening methods; 
many act against specific parasites, and few are devoid of significant 
toxicity to host cells. In addition to the direct toxicity of the drugs, 
reactions to dead and dying parasites may cause serious toxicity in 
patients.
</div>

<div id="antibacterials">
Beta-Lactam Antibiotics & Other Cell Wall Synthesis Inhibitors

Penicillins and cephalosporins are the major antibiotics that inhibit 
bacterial cell wall synthesis. They are called beta-lactams because of the 
unusual 4-member ring that is common to all their members. The beta-lactams 
include some of the most effective, widely used, and well-tolerated agents 
available for the treatment of microbial infections. Vancomycin, 
fosfomycin, and bacitracin also inhibit cell wall synthesis but are not 
nearly as important as the beta-lactam drugs. More than 50 antibiotics that 
act as cell wall synthesis inhibitors are currently available, with 
individual spectra of activity that afford a wide range of clinical 
applications.
</div>

<div id="aminoglycosides">
Aminoglycosides are structurally related amino sugars attached by 
glycosidic linkages. They are polar compounds, not absorbed after oral 
administration and must be given intramuscularly, or intravenously for 
systemic effect. They have limited tissue penetration and do not readily 
cross the blood-brain barrier. Glomerular filtration is the major mode of 
excretion, and plasma levels of these drugs are greatly affected by changes 
in renal function. Excretion of aminoglycosides is directly proportional to 
creatinine clearance. With normal renal function, the elimination half-life 
of aminoglycosides is 2–3 h. Dosage adjustments must be made in renal 
insufficiency to prevent toxic accumulation. Monitoring of plasma levels of 
aminoglycosides is important for safe and effective dosage selection and 
adjustment. For traditional dosing regimens (2 or 3 times daily), peak 
serum levels are measured 30–60 min after administration and trough levels 
just before the next dose. With once-daily dosing, peak levels are less 
important since they will naturally be high.
    </div>

    <div id="fluoroquinolones">
  The fluoroquinolones interfere with bacterial DNA synthesis by inhibiting 
topoisomerase II (DNA gyrase), especially in gram-negative organisms and 
topoisomerase IV, especially in gram-positive organisms. They block the 
relaxation of supercoiled DNA that is catalyzed by DNA gyrase, a step 
required for normal transcription and duplication. Inhibition of 
topoisomerase IV by fluoroquinolones interferes with the separation of 
replicated chromosomal DNA during cell division. Fluoroquinolones are 
usually bactericidal against susceptible organisms. Like aminoglycosides, 
the fluoroquinolones exhibit postantibiotic effects, whereby bacterial 
growth continues to be inhibited even after the plasma concentration of the 
drug has fallen below the minimum inhibitory concentration of the bacterium
</div>

<div id="antimycobacterials">
Drugs for Tuberculosis

The major drugs used in tuberculosis are isoniazid (INH), rifampin, 
ethambutol, pyrazinamide, and streptomycin. Actions of these agents on M 
tuberculosis are bactericidal or bacteriostatic depending on drug 
concentration and strain susceptibility. Appropriate drug treatment 
involves antibiotic susceptibility testing of mycobacterial isolates. 
Initiation of treatment of pulmonary tuberculosis usually involves a 3- or 
4-drug combination regimen depending on the known or anticipated rate of 
resistance to isoniazid (INH). Directly observed therapy (DOT) regimens are 
recommended in noncompliant patients and in drug-resistant tuberculosis.
 </div>  

        </div>
4

4 に答える 4

2

CSS を使用します。すべての内部 div をコンテナーにネストし、クラスまたは id 属性をその div に追加します。例えば:

<div id="container">
    <div id="introduction">asdfasdfasdfasd</div>
    <div id="fluoroquinolones">more stuff</div>
</div>

デフォルトでは、ネストされたすべての div の表示を none にします

<style type="css/text">
    #container div { display: none; }
</style>

リンクを含むリストに識別子を添付することもお勧めします。また、JavaScript を使用して、リンクをクリックすると開くようにします。より迅速な開発と開発の容易さのために、JQuery をお勧めします。

次のような JavaScript コマンドを使用して、すべての要素を選択できます。

document.getElementById("test").getElementsByTagName("a")

そして、選択した div 要素をオンにする onclick を追加しますが、他のすべての要素をオフにします (CSS 表示を変更します)。

-- 編集: JavaScript の例

<script type="javascript/text">
var x = document.getElementById("test").getElementsByTagName("a");
var last = "";
for (i in x) {
    x[i].onclick = function(e) {
        var current = this.hash.substr(1);
        if (last!="")
            document.getElementById(last).style.display = "none";
        document.getElementById(this.hash.substr(1)).style.display = "block";
        last = current;
        e.preventDefault();
        return false;
    };
}
</script>

これは、ID「test」でリスト要素コンテナーを識別したことを前提としています。

JQuery を使用すると、一連のキーストロークを節約できたはずです。

-- フィドルで編集: http://jsfiddle.net/7B9sP/

于 2013-03-19T18:49:13.637 に答える
2

jqueryの使用をお勧めします

ハッシュを簡単に操作できるプラグインがいくつかあります。

http://www.asual.com/jquery/address/

http://benalman.com/projects/jquery-bbq-plugin/

于 2013-03-19T18:47:31.447 に答える
1

これを使って:

$(document).ready(function() {
    $('li a').click(function() {
        var getID = $(this).attr('href');
        $('.alldivs').fadeOut();
        $(getID).fadeIn();
        // or $(getID).slideDown();
        // or something you want. see in jquery.com
        // don't forget to use a plugin jquery in you head page html.
        return false;
    });
});

div の「紹介」を非表示に割り当てclass="alldivs"、選択した div を表示します。お役に立てば幸いです。

于 2013-03-19T18:50:44.733 に答える
1
    <div>
        <ul>
            <li><a name="introduction" href="#introduction">Introduction to antimicrobials</a></li>
            <li><a name="introduction" href="#antifungals">Antifungal Drugs</a></li>
        </ul>

        <div id="introduction" class="description">
            Viruses: Smallest pathogens, programmed to infect only certain 
            body cells. Virus uses a body cells to reproduce itself it cannot be 
            treated with medication.
        </div>

        <div id="antifungals" class="description">
            Amphotericin B continues to be an important drug for the treatment of 
             systemic fungal infections. However, several azoles and echinocandins are 
             proving to be just as effective in some systemic mycoses with less risk of 
             toxic effects.
        </div>
     </div>

これを html と見なし、次の CSS を追加します。

   .description {
       display: none;
    }

    .displaying {
       display: block;
    }

次に、次の jquery コードを本体に追加します。ページに jquery ライブラリを必ずインポートしてください。

  $('.data-link').on('click', function(event) {
     var id = $(this).attr('name');
     if($('#' + id).hasClass('description')) {
        $('#' + id).removeClass('description').addClass('displaying');
      } else {
        $('#' + id).removeClass('displaying').addClass('description');
      }
   });

それを実証するために簡単なjsfiddleを書きました。

http://jsfiddle.net/kG9wn/

もう一度クリックすると、コードは div も非表示にします。

于 2013-03-19T18:58:23.200 に答える