0

私はこのHTMLを持っています:

<div class="produtoListaDescTamanho">
  <label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="9"><b>Frango Teriaky R$ 6.00&nbsp;&nbsp;&nbsp;</b></label>
  <label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="8"><b>Camarão R$ 6.00&nbsp;&nbsp;&nbsp;</b></label>
  <label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="7"><b>Salmão e Queijo Qualho R$ 6.00&nbsp;&nbsp;&nbsp;</b></label>
  <label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="6"><b>Salmão R$ 6.00&nbsp;&nbsp;&nbsp;</b></label>
  <label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="10"><b>Mignom R$ 6.00&nbsp;&nbsp;&nbsp;</b></label><br><br>
 </div>

この Jquery が検証のために機能しないのは、Jquery、var tamanho = undefined を使用した入力ラジオです。Jクエリコード:

$(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

4

2 に答える 2

1

jqueryでこの名前セレクターを使用してみてください。

var tamanho = $('input:radio[name="tamanho-324"]:checked').val();
于 2013-03-06T11:38:24.493 に答える
0
repalce   

temp = document.getElementsByName('tamanho-'+this.id);
$(temp ).removeAttr('checked');
$(temp ).attr('previousValue', false);


with

$('#tamanho-'+this.id ).each(function( index ) {
this.removeAttr('checked');
this.attr('previousValue', false);
});
于 2013-03-06T11:44:34.360 に答える