DEV Community

Discussion on: Text To Speech In 3 Lines Of JavaScript

Collapse
 
nayyhah profile image
Neha Jha • Edited

You can add an id in p tag
say, id="content" is added in p tag

now access the content inside the p tag using this id and replace in above code like this:
msg.text = document.getElementById("content").textContent;