How to get first character of string?

后端 未结 17 2546
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 09:43

I have a string, and I need to get its first character.

var x = \'somestring\';
alert(x[0]); //in ie7 returns undefined

How can I fix my co

17条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 10:41

    in JQuery you can use: in class for Select Option:

    $('.className').each(function(){
        className.push($("option:selected",this).val().substr(1));
    });
    

    in class for text Value:

    $('.className').each(function(){
        className.push($(this).val().substr(1));
    });
    

    in ID for text Value:

    $("#id").val().substr(1)
    

提交回复
热议问题