<tfoot id='Gh7hU'></tfoot>

    <i id='Gh7hU'><tr id='Gh7hU'><dt id='Gh7hU'><q id='Gh7hU'><span id='Gh7hU'><b id='Gh7hU'><form id='Gh7hU'><ins id='Gh7hU'></ins><ul id='Gh7hU'></ul><sub id='Gh7hU'></sub></form><legend id='Gh7hU'></legend><bdo id='Gh7hU'><pre id='Gh7hU'><center id='Gh7hU'></center></pre></bdo></b><th id='Gh7hU'></th></span></q></dt></tr></i><div id='Gh7hU'><tfoot id='Gh7hU'></tfoot><dl id='Gh7hU'><fieldset id='Gh7hU'></fieldset></dl></div>

      <legend id='Gh7hU'><style id='Gh7hU'><dir id='Gh7hU'><q id='Gh7hU'></q></dir></style></legend>

      <small id='Gh7hU'></small><noframes id='Gh7hU'>

      • <bdo id='Gh7hU'></bdo><ul id='Gh7hU'></ul>
      1. 检查字符串中的第一个字符

        时间:2023-08-07
            <tbody id='MQWTK'></tbody>
        • <i id='MQWTK'><tr id='MQWTK'><dt id='MQWTK'><q id='MQWTK'><span id='MQWTK'><b id='MQWTK'><form id='MQWTK'><ins id='MQWTK'></ins><ul id='MQWTK'></ul><sub id='MQWTK'></sub></form><legend id='MQWTK'></legend><bdo id='MQWTK'><pre id='MQWTK'><center id='MQWTK'></center></pre></bdo></b><th id='MQWTK'></th></span></q></dt></tr></i><div id='MQWTK'><tfoot id='MQWTK'></tfoot><dl id='MQWTK'><fieldset id='MQWTK'></fieldset></dl></div>
              <bdo id='MQWTK'></bdo><ul id='MQWTK'></ul>
            • <legend id='MQWTK'><style id='MQWTK'><dir id='MQWTK'><q id='MQWTK'></q></dir></style></legend>
                <tfoot id='MQWTK'></tfoot>

                  <small id='MQWTK'></small><noframes id='MQWTK'>

                  本文介绍了检查字符串中的第一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有输入框.我正在寻找一种方法来启动 alert() 如果给定字符串的第一个字符等于 '/'...

                  I have input-box. I'm looking for a way to fire-up alert() if first character of given string is equal to '/'...

                  var scream = $( '#screameria input' ).val();
                  
                  if ( scream.charAt( 0 ) == '/' ) {
                  
                    alert( 'Boom!' );
                  
                  }
                  

                  目前这是我的代码.它不起作用,我认为这是因为该浏览器不知道何时检查该字符串...每当用户输入/"作为第一个字符时,我都需要该警报.

                  It's my code at the moment. It doesn't work and I think that it's because that browser doesn't know when to check that string... I need that alert whenever user inputs '/' as first character.

                  推荐答案

                  试试这个:

                  $( '#screameria input' ).keyup(function(){ //when a user types in input box
                      var scream = this.value;
                      if ( scream.charAt( 0 ) == '/' ) {
                  
                        alert( 'Boom!' );
                  
                      }
                  })
                  

                  小提琴:http://jsfiddle.net/maniator/FewgY/

                  这篇关于检查字符串中的第一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:javascript中的字符到十六进制 下一篇:使用 shift 修饰符从键码中获取键字符(值)

                  相关文章

                  最新文章

                    <bdo id='l7Dzp'></bdo><ul id='l7Dzp'></ul>

                1. <small id='l7Dzp'></small><noframes id='l7Dzp'>

                2. <tfoot id='l7Dzp'></tfoot>
                  <i id='l7Dzp'><tr id='l7Dzp'><dt id='l7Dzp'><q id='l7Dzp'><span id='l7Dzp'><b id='l7Dzp'><form id='l7Dzp'><ins id='l7Dzp'></ins><ul id='l7Dzp'></ul><sub id='l7Dzp'></sub></form><legend id='l7Dzp'></legend><bdo id='l7Dzp'><pre id='l7Dzp'><center id='l7Dzp'></center></pre></bdo></b><th id='l7Dzp'></th></span></q></dt></tr></i><div id='l7Dzp'><tfoot id='l7Dzp'></tfoot><dl id='l7Dzp'><fieldset id='l7Dzp'></fieldset></dl></div>

                    1. <legend id='l7Dzp'><style id='l7Dzp'><dir id='l7Dzp'><q id='l7Dzp'></q></dir></style></legend>