JavaScript:事件按键

时间:2016-06-28 16:39:35

标签: javascript

我对这组代码如何通过按键盘上的“g”选择按钮感到困惑:

enter image description here

对此有何帮助?

3 个答案:

答案 0 :(得分:0)

jquery中按键的概念

$(selector).keypress(function) 

您可以关注http://www.k68.org/wp-content/uploads/2010/11/Key_Codes.htm

答案 1 :(得分:0)

使用此代码:

<div style="text-align: center; font size:12pt;"><span class="body"><a href="#">Server Rules</a>||<a href="#">Route Specific Rules</a>
    		||<a href="#">Local Information</a>
    		||<a href="#">Train & Destination Tags</a><br></div></span>
  <hr>
  <div class="centerDivR">
    <div class="rulesa">
      <div style="text-align: center;">
        <span class="h2"><i>General Rules:</i></span>
        <br>
        <br>
      </div>
      <ul>
        <li>No Advertiseing other servers</li>
        <li>Four Strike Policy
          <ol>
            <li>1st Warning</li>
            <li>2nd Warning</li>
            <li>2 Week Ban</li>
            <li>Perminate Suspension</li>
          </ol>
        </li>
        <li>Please keep foul language to a minimum</li>
        <li>Be considerate of other players</li>
        <li>Discussion or distribution of pirated or illegally acquired software is strictly prohibited</li>
      </ul>
    </div>
    <div class="rulesspace"></div>
    <div class="rulesb">
      <div style="text-align: center;">
        <span class="h2"><i>Multiplayer Server Rules:</i></span>
        <br>
        <br>
      </div>
      <ul>
        <li>No spanwing trains with out dispatcher permission</li>
        <li>No flipping switches while DS is on duty with out proper permission</li>
        <li>No passing red signals without G or P plates</li>
        <li>If a signal has stop indication but contains a G or P plate, stop, and ask DS to proceed at restricted speed</li>
        <li>Flipping switches & dropping signals without proper permission while a train is approaching is strictly prohibited.</li>
        <li>Hump Yard tags/settings are not to to be changed except by an Administrator.</li>
        <li>For the UP and BN trackage, call signals LOWER than clear.
          <br>(Clear Varients may be called)</li>
        <li>Obey all Speed limits</li>
        <li>Do not leave mainline switches open</li>
        <li>Special trains (circus trains, OCS trains, etc. may be run only with administrator permission)</li>
        <li>Running a track intended for traffic moving opposite your direction may be run ONLY with track warrant accompanying.</li>
        <li>If you need to leave with other players on the same trackage, you may step away and hold the main for 15 minutes.
          <br>If the limit is reached, your train will be saved and deleted for you to resume later.</li>
      </ul>
      </b>
    </div>
  </div>

答案 2 :(得分:0)

因为我可以阅读您提供的代码图像将起作用。 它有一个问题,即基于所提供示例的描述,捕获该元素的所有事件,这是不正确的。 他们应该是$('.btn').toggleClass("btn-like")