[development] How can I refer to the shopping cart using

Karl Giesing khzmusik at hotmail.com
Fri Jan 28 20:42:42 UTC 2011


> How can I refer to the shopping cart using document.getElementById if it
> does not have an id?

You can't.

This is where jQuery is your friend:

$(".pane-uc-cart-0").val()

...will get the value of the FIRST element with the pane-uc-cart-0 class.

jQuery ships with Drupal, and is automatically added whenever there is JavaScript, so you don't need to add the jQuery library using drupal_add_js().

FYI, class names in Drupal are usually added left-to-right, from least-specific to most-specific. So, the last class is the one that is the most specific to that particular element.

-Karl. 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110128/bd9a5377/attachment.html 


More information about the development mailing list