Android: How to select text from WebView, and highlight it onclick
<p>Hi guys in my web app i wanted to print selected text(say here content in paragraph tag). How to do it in Android WebView, how to select text using JavaScript??<br><br>
Thanks in advance..<br><br>
Here is my JavaScript code</p>

<pre><code>&lt;script type="text/JavaScript"&gt;

function SelectText()
{
    var txt = '';
     if (window.getSelection)

    {
        txt = window.getSelection();
             }
    else if (document.getSelection)
    {
        txt = document.getSelection();
            }
    else if (document.selection)
    {
        txt = document.selection.createRange().text;
            }
    else return;
document.getElementById("demo").innerHTML=  txt;
}

&lt;/script&gt;&lt;/head&gt;


 &lt;body&gt;
   &lt;p&gt;Hi man how are you?? Hope your doing good..&lt;/p&gt;
   &lt;p&gt; id="demo"&gt;&lt;/p&gt;

  &lt;button&gt; onclick="SelectText()"&gt;Selected text&lt;/button&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
