title: javascript to get next-previous paragraph of selected text in web page
body: <p>hello i want i have function to get paragraph of selected text.</p>
  
  <p>this is the function to get current paragraph of selected text</p>
  
  <pre><code>function getSelected() {
    var userSelection;
    if (window.getSelection) {
        selection = window.getSelection();
    } else if (document.selection) {
        selection = document.selection.createRange();
    }
    var parent = selection.anchorNode;
    parent = parent.parentNode;
    alert(parent.innerHTML);
  
  }
  </code></pre>
  
  <p>how can i get next-previous paragraph of selected text in web page. if i have function to get current paragraph above. (i think to use nextSibling but i don't know to implement it in code above)
  can you help me?</p>
  
  <p>-thank you-</p>