DEV Community

Discussion on: Text To Speech In 3 Lines Of JavaScript

Collapse
 
sachin123np profile image
sachin123np • Edited

How to read the web page content? suppose in html page we have

hii gud morning

how do we take reference for the p tag in order to speak the content inside the p tag?
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;