我有這樣的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