title: Make jQuery function run only inside a specific div id or class
body: <p>I have a jQuery function to change the <strong>href</strong> on a webpage.  How do I make this script only run inside the <code>#container</code> div?</p>
  
  <pre><code>$('a[href*="example.com"]').each(function(){
   var index = this.href.indexOf(".com/");
   this.href = this.href.slice(0, index+5)
  })
  </code></pre>
  
  <p>I've tried this,</p>
  
  <pre><code>$('#container').$('a[href*="example.com"]').each(function(){
   var index = this.href.indexOf(".com/");
   this.href = this.href.slice(0, index+5)
  })
  </code></pre>
  
  <p>but it doesn't work. What's wrong with the code above?</p>