我有这样的HTML:验证输入电台的jQuery不工作值检查
<div class="produtoListaDescTamanho">
<label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="9"><b>Frango Teriaky R$ 6.00 </b></label>
<label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="8"><b>Camarão R$ 6.00 </b></label>
<label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="7"><b>Salmão e Queijo Qualho R$ 6.00 </b></label>
<label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="6"><b>Salmão R$ 6.00 </b></label>
<label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="10"><b>Mignom R$ 6.00 </b></label><br><br>
</div>
和这个jQuery不工作的验证是与jQuery,VAR = tamanho未定义输入无线电。 jQuery代码:
$(document).ready(function(){$('.produtoAddCarinho').live("click",(function(){
alert(this.id);
var tamanho = $('tamanho-324:checked').val(); // or $('input[name=tamanho-'+this.id+']:checked', '#tabela_geral').val();
var produto = document.getElementById('desc-'+this.id).innerHTML;
if (tamanho == undefined)
{
$().toastmessage('showErrorToast', "Selecione o tamanho, para adiconar o produto <br><br>" + produto);
}
else
{
Inserir(this.id, tamanho, produto);
};
temp = document.getElementsByName('tamanho-'+this.id);
$(temp).removeAttr('checked');
$(temp).attr('previousValue', false);
}))});
TKS
'live'不赞成使用'on'代替.. – Deadlock 2013-03-06 11:35:40
尝试'$( '输入[名称= “tamanho - '+ this.id +'”]:检查')'(即,围绕name属性的值添加双引号)。 – nnnnnn 2013-03-06 11:37:05
元素“”不存在。你的选择器是错误的。使用'input [name ='tamanho-324']'而不是 –
2013-03-06 11:38:11