title: Check if button clicked has ID that starts with a particular String in jQuery
body: <p>I am using Twitter Bootstrap and have the following code</p>
  
  <pre><code>&lt;div class="btn-group"&gt;
  &lt;a id="id_btn_dropdown_policies" class="btn dropdown-toggle" data-toggle="dropdown"   href="#"&gt;
                          --Select-- &lt;/a&gt;
  &lt;ul class="dropdown-menu"&gt;
  &lt;li&gt;&lt;a href="#" id="id_btn_dropdown_policy_policy1"&gt;policy1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#" id="id_btn_dropdown_policy_policy2"&gt;policy2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#" id="id_btn_dropdown_policy_policy3"&gt;policy3&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#" id="id_btn_dropdown_policy_policy4"&gt;policy4&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and my function is</p>
  
  <pre><code>$(function() {
  
      $(".dropdown-menu li a").click(function() {
          //check if button clicked is of id that starts with id_btn_dropdown_policy
          $("#id_btn_dropdown_policies").text($(this).text());
          $("#id_btn_dropdown_policies").val($(this).text());
          getCategory($(this));
      });
  
  });
  </code></pre>
  
  <p>I want setting the text and value of element with id id_btn_dropdown_policies only if <code>this.id.indexof("id_btn_dropdown_policies")=0</code></p>
  
  <p>I am not able to do this in jQuery because looks like there is no indexof method. I tried</p>
  
  <pre><code>if($(this).attr('id').indexof("id_btn_dropdown_policy") == 0) {
                  alert("Matched");
              };
  </code></pre>
  
  <p>which is not correct. So what is the correct way?</p>