Gerry Studios Gerry Studios - 1 month ago 11
jQuery Question

Change element's innertext with php

I want to change a innerText of a element using php (I also use jquery); and I've tried this:

<?php
$variable = "Hello";
echo '<script>$('#element').text($variable);</script>'
?>


But it didn't work. I've also tried with:

document.getElementsById('element').innerText = $variable;

Answer

Use

 document.getElementById('element').innerHTML = $variable;

or

$('#element').html($variable);