PHP结果作为text / element字段中的变量(在'placeholder'字段中使用php输出)

问题描述:

I am loading the current bitcoin price to my webpage using:

var auto_refresh = setInterval(
     function()
     {$('.btc-price').load('gox.php');}, 10000);

I can get the current price to display with:

<div class="btc-price"></div>

But I want to use the price as a 'placeholder' in an input field:

<input placeholder="[current bitcoin price here]" />

Is this possible?

我正在使用以下方法将当前比特币价格 code>加载到我的网页: p> \ n

  var auto_refresh = setInterval(
 function()
 {$('。btc-price')。load('gox.php');},10000); 
   code>  pre> 
 
 

我可以显示当前价格: p>

 &lt; div class =“btc-price”&gt;&lt;  ; / div&gt; 
  code>  pre> 
 
 

但我想在输入字段中将价格用作“占位符”: p>

 &lt; input placeholder =“[current bitcoin price here]”/&gt; 
  code>  pre> 
 
 

这可能吗? p> div>

You can provide an id to your input field and then set the attribute placeholder through jquery.

var auto_refresh = setInterval(
     function()
     {$.get('gox.php', function (data) {
          $("#inputid").attr('placeholder', data);
     });}, 10000);