首页 > 编程语言 > 详细

javascript indexOf startWith

时间:2016-01-29 00:05:06      阅读:128      评论:0      收藏:0      [点我收藏+]

    判断字符串是否以XX开头

    1.切割转换   var str = "ababaa",tags = jquery.trim(str);

    2. indexOf方法运行   !tags.indexOf("aba") == true, 说明 tags以“abc” 开头,否则不是以“abc”开头。

    3. 说明   indexOf()方法返回-1,0,>0的正数,而javascript number对象 等于0时能转换成false,其他值都只能转换成true;

       The indexOf() method returns the position of the first occurrence of a specified value in a string.

    If the Boolean object has no initial value, or if the passed value is one of the following:

       0, -0, null, "", false, undefined, NaN
       the object it is set to false. For any other value it is set to true (even with the string "false")!

       This method returns -1 if the value to search for never occurs.

javascript indexOf startWith

原文:http://www.cnblogs.com/rocky-fang/p/5167532.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!