title: How to know if selected text is inside a specific div
body: <p>I have two divs as shown below:</p>
  
  <pre><code>&lt;div id="div1"&gt;
  &lt;p&gt;something&lt;/p&gt;
  &lt;div&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;Div1&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="div2"&gt;
  &lt;p&gt;something else&lt;/p&gt;
  &lt;div&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;Div2&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;button type="button"&gt;Check&lt;/button&gt;
  </code></pre>
  
  <p>Now, I want to know when some text is selected and then the button pressed, if the selected text is under "div1" or not. How can I do that?</p>
  
  <p>Edit: And the solution has to work in IE-7 and above.</p>