jQuery表单使用$.ajax发布
我在wordpress上安装了投票系统,如果我只有一篇文章,如果我有更多的文章,那么一切都很好,AJAX文章只针对第一种形式 因此,每篇文章都有一个HTML表单:jQuery表单使用$.ajax发布,jquery,Jquery,我在wordpress上安装了投票系统,如果我只有一篇文章,如果我有更多的文章,那么一切都很好,AJAX文章只针对第一种形式 因此,每篇文章都有一个HTML表单: <form method="post" id="vote_<?php the_ID(); ?>" class="vote" name="vote"> <input type="hidden" id="vote_post_id" name="vote_post_id" value="<?php
<form method="post" id="vote_<?php the_ID(); ?>" class="vote" name="vote">
<input type="hidden" id="vote_post_id" name="vote_post_id" value="<?php the_ID(); ?>" />
<input type="hidden" id="vote_count" name="vote_count" value="1" />
<span class="votes_count"><?php echo get_post_meta($post->ID, 'votes', true); ?></span>
<input type="submit" name="vote_up" class="vote_up" value="+1" />
</form>
因此,我希望这能起作用,只在已经提交的表格上。我如何做到这一点
.each()会起作用吗?如果我理解正确(如果不只是忽略我lol) 您可以使用.live函数保存对页面上每个提交按钮的引用
$('.vote-up').live('click', function(){
//do your ajax calls here...
});
这将为每个投票按钮创建一个点击事件
$('.vote-up').live('click', function(){
//do your ajax calls here...
});