【发布时间】:2011-01-25 21:00:35
【问题描述】:
从上一个问题开始,这里有一个函数,用于确定由单选按钮和复选框选择的哪些元素加载到右侧标志上,以及哪些元素通过“blank2.html”加载出来。问题是它在错误的时间点加载了错误的元素。这是代码。
function product_analysis_global() {
$(':checked').each(function() {
var alt = $(this).attr('alt');
var title = $(this).attr('title');
if ($('#product_quantity_PRI_' + alt).attr('title') != title) {
$('#product_' + alt).load(title);
$('#product_quantity_PRI_' + alt).attr('title', title);
$('#product_quantity_PRI_' + alt).val($(this).val());
} else if ($('#product_quantity_PRI_' + alt).attr('title') != 'http://www.divethegap.com/update/blank2.html') {
$('#product_' + alt).load('http://www.divethegap.com/update/blank2.html');
$('#product_quantity_PRI_' + alt).attr('title', 'http://www.divethegap.com/update/blank2.html');
} else return false ;
});
}
看看这里的实现,你就会明白我的意思。 http://www.divethegap.com/update/diving-trips/adventure-training 并点击 BEGINNERS 加载表单。
我认为问题在于 $(this).attr('alt') 和 $(this).attr('title') 只为选中的框收集一个属性,而不是所有属性。
我希望此代码具有的附加功能是在未选中的框中处理禁用的复选框或单选按钮并通过“blank2.html”将其加载出来
【问题讨论】: