Skip to content Skip to sidebar Skip to footer

How Can Change Value Of A Div

'
this is div a
' '
this is div b
' now how can I change the text of div dynamically by button click. here also ment

Solution 1:

This will work once the page is being loaded:

document.getElementById('diva').innerHTML = 
  <?phpecho functionThatReturnsSomeValue(); ?>;

Dynamically, you would need to do an AJAX call on the PHP file which outputs a value. You'd be better off if you used a JS framework such as jQuery, rather than implementing the AJAX call yourself.

Solution 2:

PHP cannot modify the content of the page after it has been served to the browser. However this would be trivial with a JavaScript Library such as jQuery.

Post a Comment for "How Can Change Value Of A Div"