title: Jquery, ajax, javascript - getting an element by id
body: <p>I have some ajax onclick stuff that updates this line when the value is selected from the menu:</p>
  
  <pre><code>&lt;li id="li_273" data-pricefield="special" data-pricevalue="0" &gt;
  </code></pre>
  
  <p>The intention is to take the that value (data-pricevalue) and then multiple it by the amount that is entered from another input box. Here's my function to try to make that happen:</p>
  
  <pre><code>$('#main_body').delegate('#element_240','keyup', function(e){
  
  var temp = $(this).attr("id").split('_');
  var element_id = temp[1];
  
  var price = $('#li_273').data("pricevalue"); 
  
  var ordered = $(this).val();
  
  var price_value = price * ordered;
  
  price_value = parseFloat(price_value);
  if(isNaN(price_value)){
      price_value = 0;
  }
  
  $("#li_273").data("pricevalue",price_value);
  calculate_total_payment();  
  </code></pre>
  
  <p>}); </p>
  
  <p>Except I get the following error:
  Uncaught TypeError: Cannot call method 'data' of null</p>
  
  <p>It appears as tho my attempt to get the price value out of getElementById isn't correct. Any suggestions?</p>
  
  <p><strong>UPDATE:</strong> The code above has been edited from your suggestions and thanks to all. It appears to be working just fine now.</p>