0

I have a function in my jQuery file:

function updateHTML(blocks) {
  var data   = getData(blocks),
      price  = formatPrice(data.price),
      hourly = formatCents(data.hourly),
      p      = $.priceSlider.settings;

  $(p.processor_id).text(data.processor + ' GHZ');
  $(p.ram_id).text(data.ram + ' GB');
  $(p.price_id).text('$' + price);
  $(p.storage_id).text(data.storage + ' GB');
  $(p.bandwidth_id).text(data.bandwidth + ' GB');
  $(p.blocks_id).attr('class', 'block_' + data.blocks);
  $(p.hourly_price_id).text('$' + hourly + '/hr');
}

I have to print the value contain in the last line(

$(p.hourly_price_id).text('$' + hourly + '/hr');

on the index page. how can i do this?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

Firstly $(p.hourly_price_id).text('$' + hourly + '/hr'); should be $('p.hourly_price_id').text('$' + hourly + '/hr'); as jQuery selector requires quotes. If the p tag on the page already have the class hourly_price_id, the change is done. If not, you can append such an element to wherever you like with apendTo (doc) or append (doc) depending on your likings.

Also, if you want a unique ID for the paragraph tag, use <p id="hourly_price"> and jQuery selector $('p#hourly_price').

Erica Xu
  • 545
  • 1
  • 4
  • 13