How to display in js the id and text?

Hello, please tell me how to display the id, class, and text?
Print the result through a php variable.
<script type="text/javascript">
 var result = document.getElementById("result"); 
result.innerHTML = price;

<span id="result">0</span>
March 19th 20 at 09:26
1 answer
March 19th 20 at 09:28
, I... this?
<span id="result"><?php echo $price ?></span>

Find more questions by tags JavaScriptPHP