// This line works:
var remove = jQuery(this).closest('.item').hide();
// Why doesn’t this line work in the same script a few lines down?
var discount_amount = jQuery(this).closest('.discount_amount').text();
I am just trying to get the value of the closest div with a class of .discount_amount and assign it to the variable :-/ Am I missing something here?
File is here:
http://www.extremecouponnetwork.com/templates/ja_wall/js/clip.js
HTML HERE:
<a class="clip_it" href="javascript:void(0)" onclick="jfbc.opengraph.triggerAction('1','http://www.extremecouponnetwork.com<?php echo $this->item->link; ?>') "><img src="/templates/ja_wall/images/scissors_add.png" /><span>Clip It</span></a>
<img src="/templates/ja_wall/images/animated_scissors.gif" class="ToBeAnimated">
<br />
<div class="discount_amount" style="display: !important;"><?php echo $this->item->extraFields->DiscountAmount->value; ?></div>
<div class="percent_off" style="display: !important;"><?php echo $this->item->extraFields->PercentOff->value; ?></div>
<div class="brand_avg_sale" style="display: !important;"><?php echo $this->item->extraFields->BrandAvgSale->value; ?></div>
On the assumption that the elements are, as you said in your comments, siblings, then I’d suggest:
This doesn’t consider proximity, it’ll just take the text of the first element that matches the selector string passed to the
siblings()method.