---
title: Document.getSelection()
slug: Web/API/DocumentOrShadowRoot/getSelection
tags:
  - Referencia
  - Selección
  - metodo
translation_of: Web/API/DocumentOrShadowRoot/getSelection
translation_of_original: Web/API/Document/getSelection
original_slug: Web/API/Document/getSelection
---
<p>{{APIRef("DOM")}}</p>

<p>Este método funciona exactamente igual que {{domxref("Window.getSelection()")}}; devuelve un objeto {{domxref("Selection")}} que representa el texto que se ha seleccionado en el documento.</p>