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>