且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查字符串中的第一个字符

更新时间:2021-12-12 16:36:51

试试这个:

$( '#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/