Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii ,

I have written an html code ,And a div contains soem text .I need to get this text from the div .How can i get the text ? Pls help .....
Posted

1 solution

To get the text try

var content = document.getElementById("MyDiv").innerText;
        alert(content);



to get the html use

var content = document.getElementById("MyDiv").innerHTML;
        alert(content);


Here MyDiv is the id of the div
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900