title: How do I check if string contains substring?
body: <p>I have a shopping cart that displays product options in a dropdown menu and if they select "yes", I want to make some other fields on the page visible. </p>
  
  <p>The problem is that the shopping cart also includes the price modifier in the text, which can be different for each product. The following code works:</p>
  
  <pre><code>$(document).ready(function() {
      $('select[id="Engraving"]').change(function() {
          var str = $('select[id="Engraving"] option:selected').text();
          if (str == "Yes (+ $6.95)") {
              $('.engraving').show();
          } else {
              $('.engraving').hide();
          }
      });
  });
  </code></pre>
  
  <p>However I would rather use something like this, which doesn't work:</p>
  
  <pre><code>$(document).ready(function() {
      $('select[id="Engraving"]').change(function() {
          var str = $('select[id="Engraving"] option:selected').text();
          if (str *= "Yes") {
              $('.engraving').show();
          } else {
              $('.engraving').hide();
          }
      });
  });
  </code></pre>
  
  <p>I only want to perform the action if the selected option contains the word "Yes", and would ignore the price modifier.</p>