Home  >  Article  >  Web Front-end  >  jquery determines whether it contains a string

jquery determines whether it contains a string

藏色散人
藏色散人Original
2020-12-17 10:41:033231browse

How jquery determines whether it contains a string: First create a code sample file; then use regular expressions and the "if(str.indexOf(tag)!=-1){}" statement to realize the judgment. .

jquery determines whether it contains a string

The operating environment of this tutorial: windows7 system, jquery1.10.0 version. This method is suitable for all brands of computers.

Recommended: jquery video tutorial

jquery determines whether a certain string exists in a string

Use jquery to determine whether a certain string exists in a string Implementation code of string

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

The above is the detailed content of jquery determines whether it contains a string. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn