I have the following hidden jQuery tab: HTML
<div id="tabs-5" class="quote-hidden">
<div id="quote">
</div>
</div>
I am filling the “quote” div dynamically and making it visible with: jQuery
$(document).ready(function() {
$("#button1").click(function(){
var request = $.ajax({
cashe: "true",
url: "quote_data.php",
type: "POST",
data: {
state : x,
age : y,
gender : z
}
});
request.done( function(html){
$("#quote").html(html);
$(".quote-hidden").fadeIn(2000);
$( "#tabs" ).tabs( "option", "active", 4);
});
}):
});
So far so good. The problem is that I can’t seem to use jQuery to select any of the new elements to perform an action. For example, in the ajax loaded html I can’t select any radio button clicks to change the background-color of the row it’s in or remove the currently “highlighted” row background color: HTML
<tr class=”quote_tr”>
<td style="text-align: center"><input name="level" value="5000" type="radio">$5,000</td>
<td>…</td>
<td>…</td>
</tr><tr class=”quote_tr”>
<td style="text-align: center"><input name="level" value="6000" type="radio">$6,000</td>
<td>…</td>
<td>…</td>
</tr><tr class=”quote_tr active_tr”>
<td style="text-align: center"><input name="level" value="7000" type="radio">$7,000</td>
<td>…</td>
<td>…</td>
</tr>
jQuery
$(document).ready(function() {
$(".level_choice").click(function(){
$(this).parent("tr").addClass("active_tr");
});
});
I have also tried using “.on” for the new elements that belong to the div with id=”quote” in the DOM: jQuery
$("#quote").on('click', '.quote_table td', function(){
Still doesn’t work. Seems everything I try (that I have found in previous questions) doesn’t work.
A little guidance would be greatly appreciated.
Thanks
$(document).ready(function() {
$("#button1").click(function(){
var f = 0;
var message = "";
var x = document.forms["quote_form1"]["state_select"].value;
var y = parseInt(document.forms["quote_form1"]["age_select"].value);
var z = document.forms["quote_form1"]["gender"].value;
if (x === null || x === "") {
message += "Please select the insured's state of residence.\n";
var f = f + 1;
}if (y === null || y === 0) {
message += "Please select the insured's current age.\n";
var f = f + 1;
}if (z === null || z === "") {
message += "Please indicate the insured's gender.\n";
var f = f + 1;
}if (f > 0){
alert(message);
return false;
}if (f === 0){
var request = $.ajax({
cashe: "true",
url: "quote_data.php",
type: "POST",
data: {
state : x,
age : y,
gender : z
}
});
request.done( function(html){
$("#quote").html(html);
$(".quote-hidden").fadeIn(2000);
$( "#tabs" ).tabs( "option", "active", 4);
});
}
});
});
HTML:
<table class="quote_table" style="width: 95%">
<tbody>
<tr>
<td class="col-titles" style="padding:0 10px 0 10px"> </td>
<td colspan="2" class="col-titles" style="padding:0 10px 0 10px">Monthly Cost</td>
</tr>
<tr style="margin-bottom: 20px">
<td class="col-titles" style="padding:0 10px 0 10px">Protection Amount</td>
<td class="col-titles" style="padding:0 10px 0 10px">Direct Billing</td>
<td class="col-titles" style="padding:0 10px 0 10px">ACH Draft</td>
</tr>
<tr>
<td><hr style="margin:4px 10px 10px 10px"></td>
<td colspan="2"><hr style="margin:4px 10px 10px 10px"></td>
</tr>
<tr class="quote_tr">
<td class="level_choice" style="text-align: center">
<input class="level_choice" name="level" value="5000" type="radio">   $5,000
</td>
<td style="text-align: center">$38.10</td>
<td style="text-align: center">$34.93</td>
</tr>
<tr class="quote_tr">
<td class="level_choice" style="text-align: center">
<input class="level_choice" name="level" value="7000" type="radio">   $7,000
</td>
<td style="text-align: center">$53.34</td>
<td style="text-align: center">$48.90</td>
</tr>
<tr class="quote_tr active_tr">
<td class="level_choice" style="text-align: center">
<input class="level_choice" name="level" value="10000" type="radio" checked="">  $10,000
</td>
<td style="text-align: center">$76.20</td>
<td style="text-align: center">$69.85</td>
</tr>
</tbody>
</table>