试图从段落元素中获取价值 [英] Trying to get value from paragraph element
本文介绍了试图从段落元素中获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<p id="demo2">x</p>
我已插入现在我使用API尝试获取此值的一个值。
x是该API的值
我尝试过:
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:
var area=document.getElementById("demo2").innerHTML;
推荐答案
您的代码很好。请检查您缺少的内容。
i再次重写代码,它是找工作。
html部分:
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>
这篇关于试图从段落元素中获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文