Home > Article > Web Front-end > jquery determines whether it contains a string
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. .
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!