[英]JQuery radio input on click form submit
选择单选按钮时,我有一个要提交的表单。 我已经尝试了一些方法来使其工作,但是没有。
我的表单是这样的(仅用于广播的一个无线电选项,但原始无线电选项有20个选项):
<form action="http://spartanas.com.br/novo/wp-comments-post.php" method="post" id="votoscommentform" class="comment-form">
<div class="anuncio vitrine">
<a href="http://spartanas.com.br/novo/ninasalvattori/">
<div style="position: absolute; width: 172px; height: 285px;" class="fphover"> </div>
<img src="http://spartanas.com.br/novo/wp-content/plugins/nextcellent-gallery-nextgen-legacy/nggshow.php?pid=982" style="width:172px;height:285px">
</a>
<div class="infos">Nina Salvattori<br>Hotéis e Motéis</div>
<div style="text-align:center"><strong>1 Voto</strong><br>
<p><input onchange="this.form.submit();" value="6019" id="6019" name="comment" type="radio"><label for="6019">Votar</label></p></div></div>
<p class="form-submit">
<input name="submit" id="votarcomentform" value="Votar" type="submit">
<input name="comment_post_ID" value="6183" id="comment_post_ID" type="hidden">
<input name="comment_parent" id="comment_parent" value="0" type="hidden">
</p>
<input id="_wp_unfiltered_html_comment_disabled" name="_wp_unfiltered_html_comment" value="f33d177e03" type="hidden"><script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>
</form>
如您所见,我尝试使用onchange事件提交此版本,但是我也尝试使用JQuery:
<script>
jQuery(document).ready(function($) {
$('input[type="radio"][name="comment"]').click(function() {
$(this).closest("form").submit();
});
});
</script>
我究竟做错了什么?
您可以使用更改事件...
<script> jQuery(document).ready(function($) { $('input[type="radio"][name="comment"]').change(function() { $(this).closest("form").submit(); }); }); </script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.