I have several radio buttons that are dynamically created using javascript. I need to figure out how to refer to text in a div (also generated dynamically) Here is an html example:
<div>
<div class="div_ceck"><input id="shipping_service_1" name="sid" value="1" type="radio"></div>
<div class="free"><label for="shipping_service_1" id="shipping_service_price_1">Free</label></div>
<br class="clr">
<div class="div_ceck"><input id="shipping_service_2" name="sid" value="2" type="radio"></div>
<div class="free"><label for="shipping_service_2" id="shipping_service_price_2">14.00</label></div>
</div>
So, when the dynamic button "shipping_service_2" is pressed, I would like to warn the text "14.00" - "shipping_service_price_2 id".
Here is my (non-working) code so far
$("input[name='sid']").live("change", function() {
var id = $(this).val();
alert($("#shipping_service_price_" + id).text())
})
});
EDIT: Thanks for the answers. The project code created incorrect html, so I could not select the text. The html above was just used for testing and actually works (yes, I'm moran)
source
share