0
点赞
收藏
分享

微信扫一扫

jquery判断字符串中是否存在某个的字符串


有两种方式:
1)test
2)indexOf

$(function(){
  var str="sunny,woo";
  var sear=new RegExp(',');
  if(sear.test(str)){
  alert('Yes');
  }
  var tag=',';
  if(str.indexOf(tag)!=-1){
  alert('Yes');
  }
  });

举报

相关推荐

0 条评论