因此.click(),当我单击<a>..glossNav.words.letter
这是我尝试过的:
$(".letter").click(function(){
    var whichLetter = $(this).children("span").text();
    var selectedGloss = "#glossary-" + whichLetter;
    $(".words").fadeOut(200);
    $('.letter').removeClass('underline');
    $(selectedGloss).delay(200).fadeIn(200);
    $(this).addClass('underline');
      if($(selectedGloss).children(".glossNav").length > 0) // There isn't always a nav.
      {
            alert("Yippee!");
            $(selectedGloss).children(".glossNav").first().click();
      }
});
“伊皮!” 成功报警。
这是我的导航 HTML(这是我正在构建的词汇表):
<div id="modelglossary"><div class="letterBar">
    <a href="javascript:void(0)" class="letter" id="selector-A">
        <span>A</span>
    </a>
    <a href="javascript:void(0)" class="letter" id="selector-B">
        <span>B</span>
    </a>
    <a href="javascript:void(0)" class="letter" id="selector-C">
        <span>C</span>
    </a>
.... and so on
</div>
以下是 HTML 的大部分内容:
<div class="words" id="glossary-S">
    <div id="s-page-1" class="glossPage">
        <span class="glossBlock">
            <strong>Zedcard</strong> - See <a class="wordRef" href="javascript:void(0)">Composite Card</a>.
        </span>
        <span class="glossBlock">
            <strong>Senior model</strong> - A senior model is a professional model in his 40s/50s/60s. As the average age is constantly rising, the advertisements go back more and more to older models to approach their target group. A senior model often has a good book as they can show a lot of experience or after easily being booked for ads they get publications from the beginning on.
        </span>
        <span class="glossBlock">
            <strong>Set</strong> - This is where the action of shoot takes place usually within a professional studio or within a location. It includes all the elements which make the shoot; for example the lighting, camera, art direction and art directed scenery.
        </span>
        <span class="glossBlock">
            <strong>Shooting</strong> - Shooting in general means the implementation of photo or film shoots.
        </span>
    </div>
    <div id="s-page-2" class="glossPage">
        <span class="glossBlock">
            <strong>Stock Photos</strong> - Stock photography is the supply of photographs licensed for specific uses. It is used to fulfill the needs of creative assignments instead of hiring a photographer. Today, stock images are usually presented in searchable online databases, where they are then purchased and delivered online. Often, they are produced in studios using a wide variety of models posing as professionals, stereotypes, expressing stereotypical emotions and gesticulations or involving pets.
        </span>
        <span class="glossBlock">
            <strong>Stylist</strong> - The stylist is in charge of the outfit of the model and discussing at length with the photographer or director, about theme of the shoot.
        </span>
    </div>
    <div class="glossNav">
        <a href="javascript:void(0)" page="s-page-1">1</a>
        <a href="javascript:void(0)" page="s-page-2">2</a>
    </div>
</div>