getSelectedHtml function