How to display a php variable into html

前端 未结 5 617
萌比男神i
萌比男神i 2020-12-06 13:46

I just want to know how can I display a javascript variable into html?

Below is my php code:

var duration = ;
<         


        
5条回答
  •  死守一世寂寞
    2020-12-06 14:37

    Make your code more concise with jQuery:

    (1) Add this in your :

    
    

    (2) Create an element where you want the variable to be displayed, and give it an ID, e.g.:

    
    

    (3) Add this in your JavaScript:

    var duration="";
    $('#printHere').html(duration);
    

    For your PHP, try the following two options:

    
    

    or...

    
    

提交回复
热议问题