How to get the inner text of a DIV using javascript?
P粉809110129
P粉809110129 2023-10-18 11:02:20
0
3
641

How to get the inner text of a DIV controller using java script?

P粉809110129
P粉809110129

reply all(3)
P粉790187507

Short answer:

document.getElementById("id-of-div").innerText

Considering that you've tagged your question with asp.net-mvc-3, the long answer is that it will run in the browser, not on the server (the one running ASP.NET). There is no way to immediately get content from the browser to the server without sending a request. I guess you might want to make an ajax call to the new controller action from the page, but that depends on when the text changes and what you want to do with it.

P粉277305212

Suppose you have a div declared as:

some content goes here

You can get its value in the following ways:

// javascript
document.getElementById("someDiv").innerHTML
// jquery
$("#someDiv").html()
P粉477605856

How to contact

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!