PHP结果作为文本/元素字段中的变量(在';占位符';字段中使用PHP输出)


PHP result as variable in text / element field (use php output in 'placeholder' field)

我正在使用将当前bitcoin price加载到我的网页

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

我可以用显示当前价格

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

但我想在输入字段中使用价格作为"占位符":

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

这可能吗?

您可以为输入字段提供id,然后通过jquery设置属性placeholder

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