title: jquery- how to run some code within a form only when some text within that form is selected by the user
body: <p>I want to run some code only when the user has selected some text within the form- the selected text may be the label of an input element within the form, or some text directly given within the form.</p>
  
  <p>Currently I am using the following--</p>
  
  <pre><code>$('form').each(function(){
      // the 'this' below refers to a form- any element within the form is a child of the form...
      //hence the listener checks for focus being set to any element within any form of the web page...
      $(this).children().focus(function() {
  
    ......MY CODE HERE.............
  </code></pre>
  
  <p>Is there a better way to modify the code above, so that it works only when the user has selected some text within the form?</p>