Click here to Skip to main content
16,021,125 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<p id="demo2">x</p>


I have inserted a value in this paragraph using an API now i am trying to get this value in some other method.


x is value from that API

What I have tried:

JavaScript
var area=document.getElementById("demo2").innerHTML;
Posted
Updated 22-Feb-18 23:31pm
v3
Comments
Richard Deeming 13-Feb-18 12:54pm    
What's the problem with the code you've tried?
Member 11986458 14-Feb-18 11:12am    
not showing the value
David_Wimbley 14-Feb-18 11:21am    
You need to post your html and javascript in its entirety as what you've got should work so something else is going on.
Richard Deeming 14-Feb-18 14:22pm    
The code you've shown works as expected: Demo[^]

1 solution

Hi,

your code is fine.please check what you are missing.

i have rewrite the code again and it is working find .

html part:

<p id="demo2">x</p>
 <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="showValue()" />


Script:

<script type="text/javascript">
        function showValue() {
            var area = document.getElementById("demo2").innerHTML;
            alert(area);
        }
    
    </script>
 
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