title: javascript indexof within jquery element
body: <p>I have some code here that looks for every mention of "[code]" and turns it into <code>&lt;code&gt;</code> but I only want to do this within a specific jquery element...</p>
  
  <pre><code>      function formattxt(text){
          if (text == '') return '';
  
          var start = text.indexOf('[code]');
          var end = text.indexOf('[/code]', start);
  
  ...
  </code></pre>
  
  <p>How would I do that?</p>
  
  <p>I'm looking for something simple like the following:</p>
  
  <pre><code>var start = $("#element").text.indexOf('[code]');
  var end =  $("#element").text.indexOf('[/code]', start);
  </code></pre>