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

jquery determines whether it contains a string

藏色散人
Release: 2020-12-17 10:41:03
Original
3290 people have browsed it

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');
  }
  });
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template