2

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?

4

1 回答 1

6

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);
于 2013-07-15T04:36:52.580 回答