I have the below HTML and JQuery code and i am needing some help to do the following, i have some radio buttons with freight types, when the user choose one of them i need to get its price, it is in the span with the class price. I’ve tried to use .closest() but i am getting and empty result (JQuery v1.7.2). Can anybody help me to get this?
HTML
<div class="freight">
<input type="radio" name="freight-type" id="FX" value="FX" />
<label for="FX">
<span class="blue">Fedex</span>-
<strong>US$ <span class="price">12.42</span> </strong>
<span class="small-text"> (Delivery time: <strong>3 business days)</strong></span>
</label>
</div>
JQuery
$("input[name=freight-type]").change(function() {
alert( $(this).closest(".price").text() )
});
closest() goes UP through the DOM tree, so it would starting looking in div.fregith and then go up the DOM tree from there.
try this as your selector: