Friday, July 19, 2019

[JavaScript][Example] javascript check a string contain string

<script>
var source = "I am a foo";
if(source.indexOf("foo") !== -1){
    alert("The source contains the keyword you want.");
}
</script>
Reference:
https://stackoverflow.com/questions/1789945/how-to-check-whether-a-string-contains-a-substring-in-javascript

No comments :

Post a Comment