Article

Includes method

https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js
Copy to clipboard

If we want search for a substring in a string we may use: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/jsobjects/ex20.js?actionable=true In the code above, we search for “todo” in the haystack variable by using the includes() method.

If this method finds the "todo" substring then it will return true and thus the if condition will evaluate to true and the result div will be modified to "substring found" will be executed.

<script>
$(document).ready(function(){
  XT1
});
</script>
Copy to clipboard
Send to Live Demo

Live demo

<div id="minidivpage" class="example-live"><div id="resultdiv"></div></div>

<script>    
$(document).ready(function() {
  XT1
});
</script>
<script>
  
</script>
Copy to clipboard
Press the Run Demo button to execute the scripts above.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Your browser is too small

Resize your browser to be at least 769px wide.