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?
我正在使用以下方法将当前 我可以显示当前价格: p>
但我想在输入字段中将价格用作“占位符”: p>
这可能吗? p>
div>比特币价格 code>加载到我的网页: p> \ n
var auto_refresh = setInterval(
function()
{$('。btc-price')。load('gox.php');},10000);
code> pre>
&lt; div class =“btc-price”&gt;&lt; ; / div&gt;
code> pre>
&lt; input placeholder =“[current bitcoin price here]”/&gt;
code> pre>
答
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);